├── exporters ├── geneva │ ├── .gitignore │ ├── test │ │ └── decoder │ │ │ └── kaitai │ │ │ ├── custom_decoder.h │ │ │ └── kaitaistruct.h │ ├── example │ │ └── foo_library.h │ ├── build_tools │ │ ├── 0001-geneva-exporter.patch │ │ └── ports │ │ │ └── opentelemetry-etw-metrics-exporter │ │ │ ├── portfile.cmake │ │ │ └── vcpkg.json │ ├── cmake │ │ └── ParseOsRelease.cmake │ └── include │ │ └── opentelemetry │ │ └── exporters │ │ └── geneva │ │ └── metrics │ │ ├── exporter_options.h │ │ ├── etw_data_transport.h │ │ ├── data_transport.h │ │ ├── unix_domain_socket_data_transport.h │ │ └── macros.h ├── user_events │ ├── .gitignore │ ├── example │ │ ├── logs │ │ │ ├── foo_library.h │ │ │ └── foo_library.cc │ │ └── metrics │ │ │ └── foo_library.h │ ├── .vscode │ │ └── c_cpp_properties.json │ ├── .cmake-format.py │ ├── include │ │ └── opentelemetry │ │ │ └── exporters │ │ │ └── user_events │ │ │ ├── metrics │ │ │ └── exporter_options.h │ │ │ └── logs │ │ │ ├── utils.h │ │ │ └── exporter_options.h │ ├── test │ │ └── logs_exporter_test.cc │ ├── .clang-format │ └── Docker │ │ └── Dockerfile ├── README.md ├── fluentd │ ├── example │ │ ├── log │ │ │ ├── foo_library │ │ │ │ ├── foo_library.h │ │ │ │ └── foo_library.cc │ │ │ └── main.cc │ │ ├── trace │ │ │ ├── foo_library │ │ │ │ ├── foo_library.h │ │ │ │ └── foo_library.cc │ │ │ └── main.cc │ │ ├── fluentd-docker │ │ │ ├── run.cmd │ │ │ ├── run.sh │ │ │ ├── entrypoint.sh │ │ │ ├── fluent.conf │ │ │ └── Dockerfile │ │ ├── BUILD │ │ ├── README.md │ │ └── CMakeLists.txt │ ├── vcpkg.json │ ├── include │ │ └── opentelemetry │ │ │ └── exporters │ │ │ ├── fluentd │ │ │ └── common │ │ │ │ └── fluentd_logging.h │ │ │ └── geneva │ │ │ └── geneva_exporter_options.h │ ├── CHANGELOG.md │ └── cmake │ │ └── nlohmann-json.cmake ├── geneva-trace │ ├── tools │ │ ├── nuget │ │ │ ├── opentelemetry-icon-color.png │ │ │ ├── build │ │ │ │ └── native │ │ │ │ │ └── OpenTelemetry.Cpp.Geneva.targets │ │ │ ├── README.md │ │ │ └── OpenTelemetry.Cpp.Geneva.nuspec │ │ └── build-nuget.cmd │ ├── example │ │ └── CMakeLists.txt │ └── include │ │ └── opentelemetry │ │ └── exporters │ │ └── geneva │ │ ├── geneva_logger_exporter.h │ │ └── geneva_tracer_exporter.h └── prometheus │ ├── .cmake-format.py │ ├── test │ └── CMakeLists.txt │ ├── MODULE.bazel │ ├── src │ └── push_exporter_factory.cc │ ├── include │ └── opentelemetry │ │ └── exporters │ │ └── prometheus │ │ ├── push_exporter_factory.h │ │ └── push_exporter_options.h │ ├── WORKSPACE │ ├── .bazelrc │ ├── opentelemetry-cpp-contrib-config.cmake.in │ ├── README.md │ └── .clang-format ├── instrumentation ├── httpd │ ├── .bazelversion │ ├── build.sh │ ├── tests │ │ ├── setup-tools.sh │ │ ├── run-all.sh │ │ ├── 00-apache-configtest.sh │ │ ├── 06-check-batch-spans-x1000.sh │ │ ├── 05-check-batch-spans.sh │ │ ├── 03-accept-inbound-b3.sh │ │ ├── 02-accept-inbound-trace.sh │ │ ├── 04-accept-inbound-b3-multi.sh │ │ ├── 01-create-root-span.sh │ │ └── 09-check-environment-vars.sh │ ├── setup-environment.sh │ ├── BUILD │ ├── httpd_install_otel.sh │ ├── src │ │ └── otel │ │ │ └── BUILD │ ├── .gitignore │ ├── tools │ │ ├── check-formatting.sh │ │ ├── format-bazel.sh │ │ ├── setup-tools.sh │ │ └── format-code.sh │ ├── setup-buildtools.sh │ ├── Dockerfile.cmake │ ├── create-otel-load.sh │ ├── Dockerfile │ ├── WORKSPACE │ ├── opentelemetry.conf │ ├── .clang-format │ └── CMakeLists.txt ├── nginx │ ├── .gitignore │ ├── test │ │ ├── backend │ │ │ ├── files │ │ │ │ ├── file.js │ │ │ │ └── content.txt │ │ │ ├── simple_express │ │ │ │ ├── Dockerfile │ │ │ │ ├── package.json │ │ │ │ └── index.js │ │ │ └── php │ │ │ │ ├── ignored.php │ │ │ │ ├── b3.php │ │ │ │ ├── app.php │ │ │ │ └── b3multi.php │ │ ├── .gitignore │ │ ├── instrumentation │ │ │ ├── test │ │ │ │ └── test_helper.exs │ │ │ ├── .formatter.exs │ │ │ ├── lib │ │ │ │ └── TraceProto.ex │ │ │ ├── mix.exs │ │ │ └── .gitignore │ │ ├── conf │ │ │ ├── collector.yml │ │ │ └── fastcgi_params │ │ └── docker-compose.yml │ ├── src │ │ ├── nginx_config.h │ │ ├── otel_ngx_module_modules.c │ │ ├── nginx_utils.h │ │ ├── propagate.h │ │ ├── agent_config.h │ │ ├── location_config.h │ │ ├── trace_context.h │ │ ├── script.cpp │ │ └── script.h │ ├── ci │ │ └── setup_environment.sh │ ├── config │ ├── CMakeLists.txt │ └── nginx.cmake ├── otel-webserver-module │ ├── scripts │ │ └── gyp │ │ │ └── r1919 │ │ │ ├── OWNERS │ │ │ ├── .gitignore │ │ │ ├── pylib │ │ │ └── gyp │ │ │ │ ├── generator │ │ │ │ ├── __init__.py │ │ │ │ ├── xcode_test.py │ │ │ │ ├── msvs_test.py │ │ │ │ ├── ninja_test.py │ │ │ │ └── gypsh.py │ │ │ │ ├── simple_copy.py │ │ │ │ └── flock_tool.py │ │ │ ├── gyp.bat │ │ │ ├── samples │ │ │ └── samples.bat │ │ │ ├── gyp │ │ │ ├── tools │ │ │ ├── Xcode │ │ │ │ ├── README │ │ │ │ └── Specifications │ │ │ │ │ └── gyp.pbfilespec │ │ │ ├── emacs │ │ │ │ ├── run-unit-tests.sh │ │ │ │ └── README │ │ │ └── README │ │ │ ├── AUTHORS │ │ │ ├── codereview.settings │ │ │ ├── gyp_main.py │ │ │ ├── setup.py │ │ │ ├── DEPS │ │ │ ├── data │ │ │ └── win │ │ │ │ └── large-pdb-shim.cc │ │ │ └── LICENSE │ ├── src │ │ ├── apache │ │ │ ├── .gradle │ │ │ │ └── 4.10.2 │ │ │ │ │ ├── gc.properties │ │ │ │ │ ├── fileChanges │ │ │ │ │ └── last-build.bin │ │ │ │ │ └── fileHashes │ │ │ │ │ └── fileHashes.lock │ │ │ └── ApacheTracing.h │ │ ├── util │ │ │ └── RegexResolver.cpp │ │ ├── module_version_template.h │ │ └── nginx │ │ │ ├── script.sh │ │ │ ├── config │ │ │ ├── ngx_http_opentelemetry_log.h │ │ │ └── ngx_http_opentelemetry_log.c │ ├── dist │ │ └── VERSION.txt │ ├── gradle.properties │ ├── version.properties │ ├── entrypoint.sh │ ├── settings.gradle │ ├── gradle │ │ ├── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── custom-settings │ │ │ └── example.gradle │ │ └── conf │ │ │ └── checkstyle │ │ │ └── suppressions.xml │ ├── CHANGELOG.md │ ├── include │ │ ├── util │ │ │ └── RegexResolver.h │ │ └── core │ │ │ ├── sdkwrapper │ │ │ ├── SdkEnums.h │ │ │ ├── ISdkHelperFactory.h │ │ │ ├── ISdkWrapper.h │ │ │ ├── SdkWrapper.h │ │ │ └── IScopedSpan.h │ │ │ └── api │ │ │ └── SpanNamer.h │ ├── test │ │ ├── integration │ │ │ ├── src │ │ │ │ └── test │ │ │ │ │ ├── resources │ │ │ │ │ └── testngsuites │ │ │ │ │ │ └── testng.xml │ │ │ │ │ └── java │ │ │ │ │ ├── restutils │ │ │ │ │ ├── RestClient.java │ │ │ │ │ ├── LoadGenUtils.java │ │ │ │ │ └── BaseTest.java │ │ │ │ │ ├── utils │ │ │ │ │ ├── Constants.java │ │ │ │ │ └── JsonUtils.java │ │ │ │ │ └── zipkin │ │ │ │ │ └── TraceCreationTest.java │ │ │ └── build.gradle │ │ └── unit │ │ │ ├── unit_test.cpp │ │ │ ├── mocks │ │ │ ├── mock_dummy.h │ │ │ └── mock_SdkHelperFactory.h │ │ │ └── SdkUtils_test.cpp │ ├── install.sh │ ├── .gitignore │ ├── Makefile │ ├── sonar-project.properties │ ├── build.sh │ ├── conf │ │ └── nginx │ │ │ ├── nginx.conf │ │ │ └── opentelemetry_module.conf │ ├── otel-config.yml │ └── opentelemetry_module.conf ├── spdlog │ ├── opentelemetry_spdlog_sink-config.cmake.in │ └── src │ │ └── sink.cc ├── glog │ ├── opentelemetry_glog_sink-config.cmake.in │ ├── include │ │ └── opentelemetry │ │ │ └── instrumentation │ │ │ └── glog │ │ │ └── sink.h │ └── src │ │ └── sink.cc ├── boost_log │ └── opentelemetry_boost_log_sink-config.cmake.in ├── log4cxx │ ├── opentelemetry_log4cxx_appender-config.cmake.in │ ├── example │ │ └── otel-appender.xml │ └── src │ │ └── appender.cc └── README.md ├── examples ├── ffi │ ├── cpprust │ │ ├── .gitignore │ │ ├── src │ │ │ ├── animal.hpp │ │ │ ├── lib.rs │ │ │ └── main.cpp │ │ ├── build.rs │ │ └── Cargo.toml │ ├── Cargo.toml │ └── src │ │ └── lib.rs └── README.md ├── tools └── README.md ├── docs └── README.md ├── .github ├── dependabot.yml ├── workflows │ ├── fossa.yml │ ├── geneva_trace.yml │ └── ossf-scorecard.yml ├── CODEOWNERS └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── geneva.md │ ├── fluentd.md │ ├── glog.md │ ├── httpd.md │ ├── nginx.md │ ├── spdlog.md │ ├── boost_log.md │ ├── log4cxx.md │ ├── prometheus.md │ ├── user_events.md │ ├── geneva-trace.md │ ├── otel-webserver-module.md │ └── feature_request.md ├── .gitmodules ├── .gitignore └── .clang-format /exporters/geneva/.gitignore: -------------------------------------------------------------------------------- 1 | build/ -------------------------------------------------------------------------------- /exporters/user_events/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | -------------------------------------------------------------------------------- /instrumentation/httpd/.bazelversion: -------------------------------------------------------------------------------- 1 | 3.7.2 2 | -------------------------------------------------------------------------------- /instrumentation/nginx/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/files/file.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/ffi/cpprust/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /Cargo.lock -------------------------------------------------------------------------------- /instrumentation/nginx/test/.gitignore: -------------------------------------------------------------------------------- 1 | Dockerfile.* 2 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/files/content.txt: -------------------------------------------------------------------------------- 1 | Lorem Ipsum -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/OWNERS: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /instrumentation/httpd/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | bazel build -c opt :all 4 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/apache/.gradle/4.10.2/gc.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/instrumentation/test/test_helper.exs: -------------------------------------------------------------------------------- 1 | ExUnit.start() 2 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/generator/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/dist/VERSION.txt: -------------------------------------------------------------------------------- 1 | ${moduleVersion}${moduleRelease} 2 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/apache/.gradle/4.10.2/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # Tools 2 | 3 | This directory contains OpenTelemetry C++ contrib tools. 4 | 5 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | This directory contains OpenTelemetry C++ contrib examples. 4 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | This directory contains OpenTelemetry C++ contrib documentation. 4 | -------------------------------------------------------------------------------- /exporters/README.md: -------------------------------------------------------------------------------- 1 | # Exporters 2 | 3 | This directory contains OpenTelemetry C++ community-supported exporters. 4 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.configureondemand=true 2 | org.gradle.caching=true 3 | org.gradle.parallel=true 4 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/setup-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export DEBIAN_FRONTEND=noninteractive 4 | 5 | apt-get install -qq netcat-traditional httperf 6 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/instrumentation/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/version.properties: -------------------------------------------------------------------------------- 1 | server-module-version=1.0.3 2 | release=GA 3 | nginxSupportedVersions=1.26.0,1.25.5 4 | CPP-SDK-version=1.2.0 5 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/run-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ERR=0 4 | 5 | for testfile in ??-*.sh; do 6 | ./${testfile} || ERR=1 7 | done 8 | 9 | exit $ERR 10 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/nginx_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern "C" { 4 | #include 5 | } 6 | 7 | ngx_int_t OtelNgxConfHandler(ngx_conf_t* conf, ngx_int_t last); 8 | -------------------------------------------------------------------------------- /exporters/fluentd/example/log/foo_library/foo_library.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | void foo_library(); 7 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH="/opt/rh/devtoolset-7/root/usr/bin:/usr/local/sbin:/usr/local/bin:$PATH" 4 | 5 | exec gosu root "$@" 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | labels: 8 | - "GHA" 9 | -------------------------------------------------------------------------------- /examples/ffi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ffi" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | cxx = "1.0" 8 | 9 | [build-dependencies] 10 | cxx-build = "1.0" -------------------------------------------------------------------------------- /exporters/fluentd/example/trace/foo_library/foo_library.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | void foo_library(); 7 | -------------------------------------------------------------------------------- /exporters/geneva-trace/tools/nuget/opentelemetry-icon-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-cpp-contrib/HEAD/exporters/geneva-trace/tools/nuget/opentelemetry-icon-color.png -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'otel-webserver-module' 2 | 3 | include 'test:integration' 4 | findProject(':test:integration')?.name = 'integration' 5 | 6 | -------------------------------------------------------------------------------- /exporters/user_events/example/logs/foo_library.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | void sell_fruit(std::string_view fruit); 7 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/simple_express/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-alpine 2 | 3 | COPY package.json package-lock.json index.js / 4 | RUN npm install --production 5 | 6 | CMD ["node", "index.js"] 7 | -------------------------------------------------------------------------------- /instrumentation/spdlog/opentelemetry_spdlog_sink-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") 4 | 5 | check_required_components(@PROJECT_NAME@) 6 | -------------------------------------------------------------------------------- /examples/ffi/cpprust/src/animal.hpp: -------------------------------------------------------------------------------- 1 | class Animal { 2 | public: 3 | Animal(int age) : value(age) {} 4 | int get_age() const {return value;} 5 | 6 | private: 7 | int value; 8 | }; -------------------------------------------------------------------------------- /instrumentation/glog/opentelemetry_glog_sink-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") 4 | 5 | check_required_components(@PROJECT_NAME@) 6 | -------------------------------------------------------------------------------- /instrumentation/httpd/setup-environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | apt-get install --no-install-recommends --no-install-suggests -y \ 6 | apache2 \ 7 | apache2-dev 8 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-cpp-contrib/HEAD/instrumentation/otel-webserver-module/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /instrumentation/boost_log/opentelemetry_boost_log_sink-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") 4 | 5 | check_required_components(@PROJECT_NAME@) 6 | -------------------------------------------------------------------------------- /instrumentation/log4cxx/opentelemetry_log4cxx_appender-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") 4 | 5 | check_required_components(@PROJECT_NAME@) 6 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/instrumentation/lib/TraceProto.ex: -------------------------------------------------------------------------------- 1 | defmodule TraceProto do 2 | defmodule SpanKind do 3 | def unspecified, do: 0 4 | def internal, do: 1 5 | def server, do: 2 6 | def client, do: 3 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /exporters/geneva-trace/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(opentelemetry-geneva-trace main.cc) 2 | 3 | target_link_libraries(opentelemetry-geneva-trace ${CMAKE_THREAD_LIBS_INIT} 4 | opentelemetry_api opentelemetry_exporter_etw) -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/apache/.gradle/4.10.2/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/open-telemetry/opentelemetry-cpp-contrib/HEAD/instrumentation/otel-webserver-module/src/apache/.gradle/4.10.2/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.0.0-rc1] 2022-03-24 2 | 3 | [Dependencies] Update Opentelemetry C++ SDK version to 1.2.0 from previous version 1.0.0-rc1 ([#115](https://github.com/open-telemetry/opentelemetry-cpp-contrib/pull/115/)) 4 | -------------------------------------------------------------------------------- /exporters/user_events/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "otel_log", 5 | "defines": [ 6 | "ENABLE_LOGS_PREVIEW" 7 | ] 8 | } 9 | ], 10 | "version": 4 11 | } -------------------------------------------------------------------------------- /examples/ffi/cpprust/build.rs: -------------------------------------------------------------------------------- 1 | fn main() 2 | { 3 | cxx_build::bridge("src/lib.rs") 4 | .file("src/animal.hpp") 5 | .compile("cpp_from_rust"); 6 | 7 | println!("cargo:rerun-if-changed=src/lib.rs"); 8 | println!("cargo:rerun-if-changed=src/animal.hpp"); 9 | } -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/gyp.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright (c) 2009 Google Inc. All rights reserved. 2 | @rem Use of this source code is governed by a BSD-style license that can be 3 | @rem found in the LICENSE file. 4 | 5 | @python "%~dp0gyp_main.py" %* 6 | -------------------------------------------------------------------------------- /instrumentation/httpd/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:defs.bzl", "cc_binary") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_binary( 6 | name = "otel.so", 7 | linkshared = 1, 8 | deps = [ 9 | "//src/otel:otelmodlib", 10 | ], 11 | ) 12 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/samples/samples.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright (c) 2009 Google Inc. All rights reserved. 2 | @rem Use of this source code is governed by a BSD-style license that can be 3 | @rem found in the LICENSE file. 4 | 5 | @python %~dp0/samples %* 6 | -------------------------------------------------------------------------------- /examples/ffi/cpprust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cpprust" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["staticlib"] 8 | 9 | [dependencies] 10 | cxx = "1.0" 11 | log = "0.4" 12 | env_logger = "0.9" 13 | 14 | [build-dependencies] 15 | cxx-build = "1.0" -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /exporters/fluentd/example/fluentd-docker/run.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | pushd %~dp0 3 | echo Building docker image in %CD%... 4 | docker build --rm -t opentelemetry-fluentd ./ 5 | echo Starting OpenTelemetry-fluentd example... 6 | docker run -p 24222:24222 -it -v %CD%\log:/fluentd/log opentelemetry-fluentd 7 | popd 8 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/util/RegexResolver.h: -------------------------------------------------------------------------------- 1 | #ifndef REGEX_RESOLVER_H 2 | #define REGEX_RESOLVER_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | bool matchIgnorePathRegex(char * uri , char * regexVar); 10 | 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | #endif -------------------------------------------------------------------------------- /exporters/fluentd/example/fluentd-docker/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | pushd `pwd` 3 | echo Building docker image in current directory 4 | docker build --rm -t opentelemetry-fluentd ./ 5 | echo Starting OpenTelemetry-fluentd example... 6 | docker run -p 24222:24222 -it -v /tmp/log:/tmp/fluentd/log opentelemetry-fluentd 7 | popd 8 | -------------------------------------------------------------------------------- /exporters/prometheus/.cmake-format.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # If comment markup is enabled, don't reflow the first comment block in 5 | # eachlistfile. Use this to preserve formatting of your 6 | # copyright/licensestatements. 7 | first_comment_is_literal = True 8 | -------------------------------------------------------------------------------- /exporters/user_events/.cmake-format.py: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # If comment markup is enabled, don't reflow the first comment block in 5 | # eachlistfile. Use this to preserve formatting of your 6 | # copyright/licensestatements. 7 | first_comment_is_literal = True 8 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/gyp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2013 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | set -e 7 | base=$(dirname "$0") 8 | exec python2.7 "${base}/gyp_main.py" "$@" 9 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/php/ignored.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/simple_express/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "otel-test", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "dependencies": { 11 | "express": "^4.17.1" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/tools/Xcode/README: -------------------------------------------------------------------------------- 1 | Specifications contains syntax formatters for Xcode 3. These do not appear to be supported yet on Xcode 4. To use these with Xcode 3 please install both the gyp.pbfilespec and gyp.xclangspec files in 2 | 3 | ~/Library/Application Support/Developer/Shared/Xcode/Specifications/ 4 | 5 | and restart Xcode. -------------------------------------------------------------------------------- /exporters/geneva/test/decoder/kaitai/custom_decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef KAITAI_CUSTOM_DECODER_H 2 | #define KAITAI_CUSTOM_DECODER_H 3 | 4 | #include 5 | 6 | namespace kaitai { 7 | 8 | class custom_decoder { 9 | public: 10 | virtual ~custom_decoder(){}; 11 | virtual std::string decode(std::string src) = 0; 12 | }; 13 | 14 | } // namespace kaitai 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/gradle/custom-settings/example.gradle: -------------------------------------------------------------------------------- 1 | def run(settings, groupProjects) { 2 | settings.with { 3 | include 'utils' 4 | include 'dbmon:dbmon-api' 5 | include 'analytics:analytics-shared-rest' 6 | include 'controller:controller-api:agent' 7 | 8 | // add all your includes... 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/otel_ngx_module_modules.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern ngx_module_t otel_ngx_module; 5 | 6 | ngx_module_t* ngx_modules[] = { 7 | &otel_ngx_module, 8 | NULL, 9 | }; 10 | 11 | char* ngx_module_names[] = { 12 | "otel_ngx_module", 13 | NULL, 14 | }; 15 | 16 | char* ngx_module_order[] = { 17 | NULL, 18 | }; 19 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/php/b3.php: -------------------------------------------------------------------------------- 1 | $b3))); 10 | ?> 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "exporters/geneva-trace/third_party/opentelemetry-cpp"] 2 | path = exporters/geneva-trace/third_party/opentelemetry-cpp 3 | url = https://github.com/open-telemetry/opentelemetry-cpp 4 | [submodule "exporters/user_events/third_party/LinuxTracepoints"] 5 | path = exporters/user_events/third_party/LinuxTracepoints 6 | url = https://github.com/microsoft/LinuxTracepoints 7 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file like so: 2 | # Name or Organization 3 | 4 | Google Inc. 5 | Bloomberg Finance L.P. 6 | Yandex LLC 7 | 8 | Steven Knight 9 | Ryan Norton 10 | David J. Sankel 11 | Eric N. Vander Weele 12 | -------------------------------------------------------------------------------- /exporters/geneva-trace/include/opentelemetry/exporters/geneva/geneva_logger_exporter.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #ifndef CUSTOM_ETW_FIELDS_H 7 | #define CUSTOM_ETW_FIELDS_H 8 | #endif 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /exporters/geneva-trace/include/opentelemetry/exporters/geneva/geneva_tracer_exporter.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #ifndef CUSTOM_ETW_FIELDS_H 7 | #define CUSTOM_ETW_FIELDS_H 8 | #endif 9 | 10 | #include 11 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/00-apache-configtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that OpenTelemetry module can be loaded by httpd (Apache)" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | 11 | Error "OpenTelemetry module is required to run all tests. Run a2enmod otel" 12 | 13 | EOF 14 | 15 | } 16 | 17 | run $@ 18 | -------------------------------------------------------------------------------- /exporters/geneva/example/foo_library.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | class FooLibrary { 8 | public: 9 | static void counter_example(const std::string &name); 10 | static void histogram_example(const std::string &name); 11 | static void observable_counter_example(const std::string &name); 12 | }; 13 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/tools/emacs/run-unit-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2012 Google Inc. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | emacs --no-site-file --no-init-file --batch \ 6 | --load ert.el --load gyp.el --load gyp-tests.el \ 7 | -f ert-run-tests-batch-and-exit 8 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/resources/testngsuites/testng.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /exporters/user_events/example/metrics/foo_library.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | #include 6 | 7 | class FooLibrary { 8 | public: 9 | static void counter_example(const std::string &name); 10 | static void histogram_example(const std::string &name); 11 | static void observable_counter_example(const std::string &name); 12 | }; 13 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/nginx_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern "C" { 6 | #include 7 | } 8 | 9 | inline opentelemetry::nostd::string_view FromNgxString(ngx_str_t str) { 10 | return {(const char*)str.data, str.len}; 11 | } 12 | inline ngx_str_t ToNgxString(opentelemetry::nostd::string_view str) { 13 | return {str.size(), (u_char*)str.data()}; 14 | } 15 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/php/app.php: -------------------------------------------------------------------------------- 1 | $traceparent))); 10 | ?> 11 | -------------------------------------------------------------------------------- /exporters/geneva/test/decoder/kaitai/kaitaistruct.h: -------------------------------------------------------------------------------- 1 | #ifndef KAITAI_STRUCT_H 2 | #define KAITAI_STRUCT_H 3 | 4 | #include 5 | 6 | namespace kaitai { 7 | 8 | class kstruct { 9 | public: 10 | kstruct(kstream *_io) { m__io = _io; } 11 | virtual ~kstruct() {} 12 | 13 | protected: 14 | kstream *m__io; 15 | 16 | public: 17 | kstream *_io() { return m__io; } 18 | }; 19 | 20 | } // namespace kaitai 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/install.sh: -------------------------------------------------------------------------------- 1 | cd /otel-webserver-module 2 | ./gradlew assembleApacheModule -PbuildType=debug 3 | 4 | #Changing the httpd.conf and Adding Opentelemetry.conf 5 | cd build 6 | tar -xf opentelemetry-webserver-sdk-x64-linux.tgz 7 | mv opentelemetry-webserver-sdk /opt/ 8 | cd ../ 9 | cp opentelemetry_module.conf /etc/httpd/conf.d/ 10 | 11 | # Installing 12 | 13 | cd /opt/opentelemetry-webserver-sdk 14 | ./install.sh 15 | 16 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by gcl to get repository specific information. 2 | CODE_REVIEW_SERVER: codereview.chromium.org 3 | CC_LIST: gyp-developer@googlegroups.com 4 | VIEW_VC: http://code.google.com/p/gyp/source/detail?r= 5 | TRY_ON_UPLOAD: True 6 | TRYSERVER_PROJECT: gyp 7 | TRYSERVER_PATCHLEVEL: 0 8 | TRYSERVER_ROOT: trunk 9 | TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl 10 | 11 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/conf/collector.yml: -------------------------------------------------------------------------------- 1 | receivers: 2 | otlp: 3 | protocols: 4 | http: 5 | endpoint: 0.0.0.0:4318 6 | exporters: 7 | debug: 8 | verbosity: detailed 9 | file: 10 | path: /trace.json 11 | extensions: 12 | health_check: 13 | endpoint: 0.0.0.0:13133 14 | processors: 15 | batch: 16 | service: 17 | extensions: [health_check] 18 | pipelines: 19 | traces: 20 | receivers: [otlp] 21 | exporters: [debug, file] 22 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/propagate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "trace_context.h" 4 | #include 5 | 6 | struct OtelCarrier { 7 | ngx_http_request_t* req; 8 | TraceContext* traceContext; 9 | }; 10 | 11 | opentelemetry::context::Context ExtractContext(OtelCarrier* carrier); 12 | void InjectContext(OtelCarrier* carrier, opentelemetry::context::Context context); 13 | opentelemetry::trace::SpanContext GetCurrentSpan(opentelemetry::context::Context context); 14 | -------------------------------------------------------------------------------- /.github/workflows/fossa.yml: -------------------------------------------------------------------------------- 1 | name: FOSSA scanning 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | fossa: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4.2.2 16 | 17 | - uses: fossas/fossa-action@3ebcea1862c6ffbd5cf1b4d0bd6b3fe7bd6f2cac # v1.7.0 18 | with: 19 | api-key: ${{secrets.FOSSA_API_KEY}} 20 | team: OpenTelemetry 21 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/util/RegexResolver.cpp: -------------------------------------------------------------------------------- 1 | #include "RegexResolver.h" 2 | #include 3 | #include 4 | 5 | bool matchIgnorePathRegex(char * uri , char * regexVar){ 6 | const std::string uriString(uri); 7 | std::string regexVarString(regexVar); 8 | 9 | std::cmatch match; 10 | const std::regex pattern(regexVarString); 11 | bool ans = std::regex_match(uriString, pattern); 12 | if(ans){ 13 | return true; 14 | }else{ 15 | return false; 16 | } 17 | } -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/tools/emacs/README: -------------------------------------------------------------------------------- 1 | How to install gyp-mode for emacs: 2 | 3 | Add the following to your ~/.emacs (replace ... with the path to your gyp 4 | checkout). 5 | 6 | (setq load-path (cons ".../tools/emacs" load-path)) 7 | (require 'gyp) 8 | 9 | Restart emacs (or eval-region the added lines) and you should be all set. 10 | 11 | Please note that ert is required for running the tests, which is included in 12 | Emacs 24, or available separately from https://github.com/ohler/ert 13 | -------------------------------------------------------------------------------- /exporters/fluentd/example/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "foo_library", 3 | srcs = [ 4 | "foo_library/foo_library.cc", 5 | ], 6 | hdrs = [ 7 | "foo_library/foo_library.h", 8 | ], 9 | deps = [ 10 | "//api", 11 | ], 12 | ) 13 | 14 | cc_binary( 15 | name = "example_simple", 16 | srcs = [ 17 | "main.cc", 18 | ], 19 | deps = [ 20 | ":foo_library", 21 | "//api", 22 | "//exporters/ostream:ostream_span_exporter", 23 | "//sdk/src/trace", 24 | ], 25 | ) 26 | -------------------------------------------------------------------------------- /instrumentation/httpd/httpd_install_otel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | # when in docker image is FROM ubuntu:18.04 6 | APACHE_ALL_MODULES_DIR=/etc/apache2/mods-available 7 | # TODO check: sudo a2enmod opentel 8 | 9 | ln -fs ${SCRIPT_DIR}/opentelemetry.load ${APACHE_ALL_MODULES_DIR} 10 | ln -fs ${SCRIPT_DIR}/opentelemetry.conf ${APACHE_ALL_MODULES_DIR} 11 | 12 | a2enmod opentelemetry 13 | 14 | exit $? 15 | 16 | # TODO: fixme when in docker image FROM httpd 17 | # HTTPD_DIR=/usr/local/apache2/modules/ 18 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/RestClient.java: -------------------------------------------------------------------------------- 1 | package restutils; 2 | 3 | import io.restassured.RestAssured; 4 | import io.restassured.response.Response; 5 | import static io.restassured.RestAssured.given; 6 | 7 | public class RestClient { 8 | 9 | public static Response getResponse(String Uri){ 10 | given().when().get(Uri).then().log() 11 | .all() 12 | .assertThat() 13 | .statusCode(200); 14 | 15 | return RestAssured.given().get(Uri); 16 | } 17 | } -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/LoadGenUtils.java: -------------------------------------------------------------------------------- 1 | package restutils; 2 | 3 | import io.restassured.RestAssured; 4 | 5 | public class LoadGenUtils { 6 | 7 | public void generateLoad(String Uri, int count) { 8 | while(count > 0){ 9 | RestAssured.given().get(Uri); 10 | try { 11 | Thread.sleep(500); 12 | } catch (InterruptedException e) { 13 | e.printStackTrace(); 14 | } 15 | count --; 16 | } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # Learn about CODEOWNERS file format: 5 | # https://help.github.com/en/articles/about-code-owners 6 | # 7 | 8 | * @open-telemetry/cpp-contrib-approvers 9 | 10 | instrumentation/httpd/ @TomRoSystems @open-telemetry/cpp-contrib-approvers 11 | instrumentation/nginx/ @seemk @tobiasstadler @open-telemetry/cpp-contrib-approvers 12 | instrumentation/otel-webserver-module/ @kpratyus @ajaynagariya @debajitdas @aryanishan1001 @open-telemetry/cpp-contrib-approvers 13 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/Makefile: -------------------------------------------------------------------------------- 1 | COMMON_MAKEFILE := $(CURDIR)/$(lastword $(MAKEFILE_LIST)) 2 | 3 | DOCKER_COMPOSE_LINUX := docker-compose -f docker-compose.yml 4 | 5 | docker-clean: 6 | $(DOCKER_COMPOSE) down --rmi local -v 7 | $(DOCKER_COMPOSE) rm -f -v 8 | 9 | LINUX_x64 := $(DOCKER_COMPOSE_LINUX) run -w /webserver_agent apache_agent_centos6-x64 10 | 11 | setup-linux: 12 | $(DOCKER_COMPOSE_LINUX) build 13 | 14 | clean-linux: DOCKER_COMPOSE = $(DOCKER_COMPOSE_LINUX) 15 | clean-linux: docker-clean 16 | 17 | build-x64: clean-linux setup-linux 18 | $(DOCKER_COMPOSE_LINUX) up 19 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/gyp_main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2009 Google Inc. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | import sys 8 | 9 | # TODO(mark): sys.path manipulation is some temporary testing stuff. 10 | try: 11 | import gyp 12 | except ImportError, e: 13 | import os.path 14 | sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) 15 | import gyp 16 | 17 | if __name__ == '__main__': 18 | sys.exit(gyp.script_main()) 19 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/instrumentation/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule Instrumentation.MixProject do 2 | use Mix.Project 3 | 4 | def project do 5 | [ 6 | app: :instrumentation, 7 | version: "0.1.0", 8 | elixir: "~> 1.11", 9 | start_permanent: Mix.env() == :prod, 10 | deps: deps() 11 | # elixirc_paths: elixirc_paths(Mix.env()) 12 | ] 13 | end 14 | 15 | # defp elixirc_paths(:test), do: ["lib", "test/helpers"] 16 | # defp elixirc_paths 17 | 18 | defp deps do 19 | [ 20 | {:httpoison, "2.2.1"}, 21 | {:jason, "1.4.4"} 22 | ] 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /exporters/fluentd/example/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Simple Trace Example 3 | 4 | In this example, the application in `main.cc` initializes and registers a tracer 5 | provider from the [OpenTelemetry 6 | SDK](https://github.com/open-telemetry/opentelemetry-cpp). The application then 7 | calls a `foo_library` which has been instrumented using the [OpenTelemetry 8 | API](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/api). 9 | Resulting telemetry is directed to stdout through the StdoutSpanExporter. 10 | 11 | See [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and 12 | running the example. 13 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/module_version_template.h: -------------------------------------------------------------------------------- 1 | #ifndef __module_version_h 2 | #define __module_version_h 3 | 4 | #define MODULE_SHA1 "$headSHA1" 5 | #define MODULE_VERSION_ "$moduleVersion" 6 | #define RELEASE_ "$moduleRelease" 7 | #define FULL_MODULE_VERSION_ "$fullVersion" 8 | #define CPP_SDK_VERSION_ "$cppSDKVersion" 9 | 10 | static const char MODULE_VERSION[] = 11 | MODULE_VERSION_ RELEASE_ MODULE_SHA1; 12 | 13 | static const char FULL_MODULE_VERSION[] = 14 | FULL_MODULE_VERSION_; 15 | 16 | static const char CPP_SDK_VERSION[] = 17 | CPP_SDK_VERSION_; 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.verbose=true 2 | 3 | # Required metadata 4 | sonar.projectKey=org.sonarqube:apm-webserver-agent 5 | sonar.projectName=APM Webserver Agent 6 | 7 | # Language 8 | sonar.language=c++ 9 | 10 | # Skip the build breaker 11 | sonar.buildbreaker.skip=true 12 | 13 | # Comma-separated paths to directories with sources (required) 14 | sonar.sources=include,src 15 | sonar.exclusions=src/protos/**/* 16 | sonar.coverage.exclusions=src/protos/**/* 17 | sonar.tests=test 18 | 19 | # C++ (Community) plugin properties 20 | sonar.cxx.coverage.reportPath=coverage-report.xml -------------------------------------------------------------------------------- /exporters/prometheus/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | foreach(testname push_exporter_test) 2 | add_executable(${testname} "${testname}.cc") 3 | target_link_libraries( 4 | ${testname} 5 | ${OPENTELEMETRY_CPP_CONTRIB_GTEST_LINK_LIB_NAME} 6 | ${OPENTELEMETRY_CPP_CONTRIB_GTEST_LINK_MAIN_NAME} 7 | opentelemetry_prometheus_push_exporter 8 | prometheus-cpp::push 9 | ${CMAKE_THREAD_LIBS_INIT} 10 | ${ATFRAMEWORK_CMAKE_TOOLSET_SYSTEM_LIBRARIES}) 11 | gtest_discover_tests( 12 | ${testname} 13 | TEST_PREFIX opentelemetry_cpp_ecosystem_test.exporter.prometheus. 14 | TEST_LIST prometheus_exporter_test) 15 | endforeach() 16 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/utils/Constants.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class Constants { 4 | 5 | public static final String TRACES= "/traces?lookback=1800000&limit=9"; 6 | public static final String SERVICES= "/services"; 7 | public static final String SPANS= "/spans?serviceName=demoservice"; 8 | 9 | private static final String HTTP_PROTOCOL = "http"; 10 | private static final String BASE_URL="localhost:9411/api/v2"; 11 | public static final String ZIPKIN_URL = HTTP_PROTOCOL + "://" + BASE_URL; 12 | public static final String WEBSERVER_URL="http://localhost:9004/"; 13 | } -------------------------------------------------------------------------------- /instrumentation/httpd/src/otel/BUILD: -------------------------------------------------------------------------------- 1 | load("@rules_cc//cc:defs.bzl", "cc_library") 2 | 3 | package(default_visibility = ["//visibility:public"]) 4 | 5 | cc_library( 6 | name = "otelmodlib", 7 | srcs = glob(["*.cpp"]), 8 | hdrs = glob(["*.h"]), 9 | copts = [ 10 | "-I/usr/include/apache2", 11 | "-I/usr/include/apr-1.0", 12 | ], 13 | deps = [ 14 | "@io_opentelemetry_cpp//api", 15 | "@io_opentelemetry_cpp//exporters/ostream:ostream_span_exporter", 16 | "@io_opentelemetry_cpp//exporters/otlp:otlp_exporter", 17 | "@io_opentelemetry_cpp//sdk/src/trace", 18 | ], 19 | alwayslink = 1, 20 | ) 21 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/nginx/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | fileName=$1 3 | 4 | sed -i "s/-L\/otel-webserver-module\/build\/linux-x64\/opentelemetry-webserver-sdk\/sdk_lib\/lib\ -lopentelemetry_webserver_sdk\ -ldl\ -lpthread\ -lcrypt\ -lpcre\ -lz\ \\\/-L\/otel-webserver-module\/build\/linux-x64\/opentelemetry-webserver-sdk\/sdk_lib\/lib\ -lopentelemetry_webserver_sdk\ -ldl\ -lrt\ -lpthread\ -lcrypt\ -lpcre\ -lz\ \\\/g" $fileName 5 | sed -i "s/-L\/otel-webserver-module\/build\/linux-x64\/opentelemetry-webserver-sdk\/sdk_lib\/lib\ \\\/-L\/otel-webserver-module\/build\/linux-x64\/opentelemetry-webserver-sdk\/sdk_lib\/lib\ -lopentelemetry_webserver_sdk\ \\\/g" $fileName 6 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2009 Google Inc. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | from setuptools import setup 8 | 9 | setup( 10 | name='gyp', 11 | version='0.1', 12 | description='Generate Your Projects', 13 | author='Chromium Authors', 14 | author_email='chromium-dev@googlegroups.com', 15 | url='http://code.google.com/p/gyp', 16 | package_dir = {'': 'pylib'}, 17 | packages=['gyp', 'gyp.generator'], 18 | entry_points = {'console_scripts': ['gyp=gyp:script_main'] } 19 | ) 20 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/nginx/config: -------------------------------------------------------------------------------- 1 | ngx_addon_name=ngx_http_opentelemetry_module 2 | 3 | if test -n "$ngx_module_link"; then 4 | ngx_module_type=HTTP 5 | ngx_module_name=ngx_http_opentelemetry_module 6 | ngx_module_srcs=" \ 7 | $ngx_addon_dir/ngx_http_opentelemetry_log.c \ 8 | $ngx_addon_dir/ngx_http_opentelemetry_module.c" 9 | . auto/module 10 | else 11 | HTTP_MODULES="$HTTP_MODULES ngx_http_opentelemetry_module" 12 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS \ 13 | $ngx_addon_dir/ngx_http_opentelemetry_log.c \ 14 | $ngx_addon_dir/ngx_http_opentelemetry_module.c" 15 | fi 16 | CORE_LIBS="-lopentelemetry_webserver_sdk $CORE_LIBS" 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore 2 | # Prerequisites 3 | *.d 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Compiled Dynamic libraries 16 | *.so 17 | *.dylib 18 | *.dll 19 | 20 | # Fortran module files 21 | *.mod 22 | *.smod 23 | 24 | # Compiled Static libraries 25 | *.lai 26 | *.la 27 | *.a 28 | *.lib 29 | 30 | # Executables 31 | *.exe 32 | *.out 33 | *.app 34 | 35 | # Bazel files 36 | /bazel-* 37 | 38 | # Mac 39 | .DS_Store 40 | 41 | # Output directories 42 | /out 43 | /out.* 44 | # Indicator that the tools were deployed 45 | .buildtools -------------------------------------------------------------------------------- /exporters/geneva/build_tools/0001-geneva-exporter.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index a1b69340..bf347198 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -442,3 +442,5 @@ install( 6 | EXPORT "${PROJECT_NAME}-target" 7 | NAMESPACE "${PROJECT_NAME}::" 8 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") 9 | + 10 | + 11 | diff --git a/exporters/CMakeLists.txt b/exporters/CMakeLists.txt 12 | index 862d2c77..354bfef4 100644 13 | --- a/exporters/CMakeLists.txt 14 | +++ b/exporters/CMakeLists.txt 15 | @@ -38,3 +38,5 @@ endif() 16 | if(WITH_JAEGER) 17 | add_subdirectory(jaeger) 18 | endif() 19 | + 20 | +add_subdirectory(geneva) -------------------------------------------------------------------------------- /exporters/geneva-trace/tools/nuget/build/native/OpenTelemetry.Cpp.Geneva.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HAVE_TLD;HAVE_ABSEIL_VARIANT;%(PreprocessorDefinitions) 6 | $(MSBuildThisFileDirectory)\..\..\api\include;$(MSBuildThisFileDirectory)\..\..\exporters\etw\include;$(MSBuildThisFileDirectory)\..\..\sdk\include;%(AdditionalIncludeDirectories) 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /instrumentation/httpd/.gitignore: -------------------------------------------------------------------------------- 1 | # Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore 2 | # Prerequisites 3 | *.d 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Compiled Dynamic libraries 16 | *.so 17 | *.dylib 18 | *.dll 19 | 20 | # Fortran module files 21 | *.mod 22 | *.smod 23 | 24 | # Compiled Static libraries 25 | *.lai 26 | *.la 27 | *.a 28 | *.lib 29 | 30 | # Executables 31 | *.exe 32 | *.out 33 | *.app 34 | 35 | # Bazel files 36 | /bazel-* 37 | 38 | # Mac 39 | .DS_Store 40 | 41 | # Output directories 42 | /out 43 | /out.* 44 | # Indicator that the tools were deployed 45 | .buildtools -------------------------------------------------------------------------------- /instrumentation/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry C++ instrumentations 2 | 3 | In this directory you will find instrumentation libraries and modules. 4 | 5 | | Name | Description | 6 | |---|---| 7 | | [boost-log](./boost_log) | Boost.Log OpenTelemetry sink backend | 8 | | [glog](./glog) | OpenTelemetry (Google) glog sink | 9 | | [httpd](./httpd) | httpd (Apache) OpenTelemetry module | 10 | | [log4cxx](./log4cxx) | Log4cxx (Apache) OpenTelemetry appender | 11 | | [nginx](./nginx) | OpenTelemetry nginx module | 12 | | [spdlog](./spdlog) | OpenTelemetry spdlog sink | 13 | | [otel-webserver-module](./otel-webserver-module) | The OTEL webserver module comprises of both Apache and Nginx instrumentation. | 14 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/DEPS: -------------------------------------------------------------------------------- 1 | # DEPS file for gclient use in buildbot execution of gyp tests. 2 | # 3 | # (You don't need to use gclient for normal GYP development work.) 4 | 5 | vars = { 6 | "chrome_trunk": "http://src.chromium.org/svn/trunk", 7 | "googlecode_url": "http://%s.googlecode.com/svn", 8 | } 9 | 10 | deps = { 11 | } 12 | 13 | deps_os = { 14 | "win": { 15 | "third_party/cygwin": 16 | Var("chrome_trunk") + "/deps/third_party/cygwin@66844", 17 | 18 | "third_party/python_26": 19 | Var("chrome_trunk") + "/tools/third_party/python_26@89111", 20 | 21 | "src/third_party/pefile": 22 | (Var("googlecode_url") % "pefile") + "/trunk@63", 23 | }, 24 | } 25 | -------------------------------------------------------------------------------- /examples/ffi/src/lib.rs: -------------------------------------------------------------------------------- 1 | use opentelemetry::sdk::trace::TracerProvider; 2 | 3 | #[cxx::bridge] 4 | mod ffi { 5 | struct TracerProvider { 6 | name: String, 7 | } 8 | 9 | extern "Rust" { 10 | fn get_tracer_provider() -> &TracerProvider; 11 | } 12 | } 13 | 14 | #[derive(Default)] 15 | pub struct RustTracerProvider { 16 | provider: TracerProvider, 17 | } 18 | 19 | impl RustTracerProvider { 20 | pub fn new() -> Self { 21 | Self { 22 | provider: TracerProvider::default(), 23 | } 24 | } 25 | } 26 | 27 | pub fn get_tracer_provider() -> *mut TracerProvider { 28 | let provider = Box::new(RustTracerProvider::new().provider); 29 | Box::into_raw(provider) 30 | } -------------------------------------------------------------------------------- /exporters/prometheus/MODULE.bazel: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | module( 5 | name = "opentelemetry-cpp-contrib-prometheus", 6 | version = "1.19.0", 7 | compatibility_level = 0, 8 | repo_name = "io_opentelemetry_cpp_contrib", 9 | ) 10 | 11 | bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") 12 | bazel_dep(name = "opentelemetry-cpp", version = "1.19.0", repo_name = "io_opentelemetry_cpp") 13 | bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") 14 | 15 | bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") 16 | -------------------------------------------------------------------------------- /exporters/fluentd/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", 3 | "name": "opentelemetry-cpp-fluentd", 4 | "version-semver": "2.0.0", 5 | "description": "mdsd/fluentd exporter for OpenTelemetry C++", 6 | "homepage": "https://github.com/niande-xbox/opentelemetry-cpp-contrib/tree/main/exporters/fluentd", 7 | "license": "Apache-2.0", 8 | "dependencies": [ 9 | "curl", 10 | "nlohmann-json", 11 | "opentelemetry-cpp", 12 | { 13 | "name": "vcpkg-cmake", 14 | "host": true 15 | }, 16 | { 17 | "name": "vcpkg-cmake-config", 18 | "host": true 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /exporters/fluentd/example/fluentd-docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #source vars if file exists 4 | DEFAULT=/etc/default/fluentd 5 | 6 | if [ -r $DEFAULT ]; then 7 | set -o allexport 8 | . $DEFAULT 9 | set +o allexport 10 | fi 11 | 12 | # If the user has supplied only arguments append them to `fluentd` command 13 | if [ "${1#-}" != "$1" ]; then 14 | set -- fluentd "$@" 15 | fi 16 | 17 | # If user does not supply config file or plugins, use the default 18 | if [ "$1" = "fluentd" ]; then 19 | if ! echo $@ | grep ' \-c' ; then 20 | set -- "$@" -c /fluentd/etc/${FLUENTD_CONF} 21 | fi 22 | 23 | if ! echo $@ | grep ' \-p' ; then 24 | set -- "$@" -p /fluentd/plugins 25 | fi 26 | fi 27 | 28 | exec "$@" 29 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/restutils/BaseTest.java: -------------------------------------------------------------------------------- 1 | package restutils; 2 | 3 | import io.restassured.RestAssured; 4 | import org.testng.annotations.BeforeClass; 5 | import org.testng.annotations.BeforeSuite; 6 | 7 | import static utils.Constants.WEBSERVER_URL; 8 | import static utils.Constants.ZIPKIN_URL; 9 | 10 | public class BaseTest { 11 | 12 | private String ZIPKIN_SERVICE_NAME = "zipkin"; 13 | private LoadGenUtils loadGenUtils = new LoadGenUtils(); 14 | 15 | @BeforeSuite 16 | public void setup() { 17 | RestAssured.baseURI = ZIPKIN_URL; 18 | } 19 | 20 | @BeforeClass 21 | public void generateLoad(){ 22 | loadGenUtils.generateLoad(WEBSERVER_URL, 90); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/06-check-batch-spans-x1000.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that 1000 requests creates 1000 spans with batch processing" 4 | 5 | . tools.sh 6 | 7 | TOTAL_SPANS=1000 8 | 9 | setup_test () { 10 | 11 | cat << EOF > ${HTTPD_CONFIG} 12 | OpenTelemetryExporter file 13 | OpenTelemetryPath ${OUTPUT_SPANS} 14 | OpenTelemetryBatch 10 5000 5 15 | EOF 16 | 17 | } 18 | 19 | run_test() { 20 | httperf --timeout=5 --client=0/1 --server=${ENDPOINT_ADDR} --port=${ENDPOINT_PORT} --uri=/ --rate=150 --send-buffer=4096 --recv-buffer=16384 --num-conns=${TOTAL_SPANS} --num-calls=1 21 | } 22 | 23 | check_results() { 24 | echo Checking that all ${TOTAL_SPANS} were created 25 | count '{' ${TOTAL_SPANS} # span count is good 26 | } 27 | 28 | run $@ 29 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/data/win/large-pdb-shim.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file is used to generate an empty .pdb -- with a 4KB pagesize -- that is 6 | // then used during the final link for modules that have large PDBs. Otherwise, 7 | // the linker will generate a pdb with a page size of 1KB, which imposes a limit 8 | // of 1GB on the .pdb. By generating an initial empty .pdb with the compiler 9 | // (rather than the linker), this limit is avoided. With this in place PDBs may 10 | // grow to 2GB. 11 | // 12 | // This file is referenced by the msvs_large_pdb mechanism in MSVSUtil.py. 13 | -------------------------------------------------------------------------------- /instrumentation/log4cxx/example/otel-appender.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/zipkin/TraceCreationTest.java: -------------------------------------------------------------------------------- 1 | package zipkin; 2 | 3 | import org.testng.annotations.Test; 4 | import restutils.BaseTest; 5 | import restutils.ValidationUtils; 6 | 7 | public class TraceCreationTest extends BaseTest { 8 | ValidationUtils validationUtils = new ValidationUtils(); 9 | 10 | @Test 11 | public void checkServiceName() throws Exception { 12 | validationUtils.verifyAllServices(); 13 | 14 | } 15 | 16 | @Test 17 | public void checkSpans() throws Exception { 18 | validationUtils.verifyAllSpans(); 19 | } 20 | 21 | @Test() 22 | public void testTraceAndSpansCreation() throws Exception { 23 | validationUtils.verifyAllTraces(); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /exporters/geneva/build_tools/ports/opentelemetry-etw-metrics-exporter/portfile.cmake: -------------------------------------------------------------------------------- 1 | include(vcpkg_common_functions) 2 | 3 | if(VCPKG_TARGET_IS_WINDOWS) 4 | vcpkg_check_linkage(ONLY_STATIC_LIBRARY) 5 | endif() 6 | 7 | vcpkg_from_github( 8 | OUT_SOURCE_PATH SOURCE_PATH 9 | REPO lalitb/opentelemetry-cpp-contrib 10 | HEAD_REF geneva-windows 11 | ) 12 | 13 | vcpkg_cmake_configure( 14 | SOURCE_PATH "${SOURCE_PATH}/exporters/geneva/" 15 | OPTIONS 16 | -DBUILD_TESTING=OFF 17 | -DBUILD_EXAMPLE=OFF 18 | ) 19 | 20 | vcpkg_cmake_install() 21 | vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT}) 22 | vcpkg_copy_pdbs() 23 | file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") 24 | file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") 25 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/instrumentation/.gitignore: -------------------------------------------------------------------------------- 1 | # The directory Mix will write compiled artifacts to. 2 | /_build/ 3 | 4 | # If you run "mix test --cover", coverage assets end up here. 5 | /cover/ 6 | 7 | # The directory Mix downloads your dependencies sources to. 8 | /deps/ 9 | 10 | # Where third-party dependencies like ExDoc output generated docs. 11 | /doc/ 12 | 13 | # Ignore .fetch files in case you like to edit your project deps locally. 14 | /.fetch 15 | 16 | # If the VM crashes, it generates a dump, let's ignore it too. 17 | erl_crash.dump 18 | 19 | # Also ignore archive artifacts (built via "mix archive.build"). 20 | *.ez 21 | 22 | # Ignore package tarball (built via "mix hex.build"). 23 | instrumentation-*.tar 24 | 25 | 26 | # Temporary files for e.g. tests 27 | /tmp 28 | -------------------------------------------------------------------------------- /instrumentation/httpd/tools/check-formatting.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ARGS="${1:-code build}" 4 | 5 | SELF=`dirname "$0"` 6 | 7 | print_help () { 8 | echo "Checking code formatting" 9 | echo "$0 [code] [build]" 10 | } 11 | 12 | check_clang () { 13 | ${SELF} ./format-code.sh 14 | } 15 | 16 | check_buildifier () { 17 | ${SELF} ./format-bazel.sh 18 | } 19 | 20 | check_all () { 21 | while [[ $# > 0 ]] ; do case "$1" in 22 | code|clang) 23 | check_clang 24 | shift 25 | ;; 26 | build|buildifier) 27 | check_buildifier 28 | shift 29 | ;; 30 | -h) 31 | print_help 32 | exit 0 33 | ;; 34 | *) 35 | print_help 36 | echo "Unknown argument: $1" >&2 37 | exit 1 38 | ;; 39 | esac done 40 | } 41 | 42 | check_all ${ARGS} 43 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/agent_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern "C" { 6 | #include 7 | } 8 | 9 | enum OtelProcessorType 10 | { 11 | OtelProcessorSimple, 12 | OtelProcessorBatch 13 | }; 14 | 15 | struct OtelNgxAgentConfig 16 | { 17 | struct 18 | { 19 | std::string endpoint; 20 | } exporter; 21 | 22 | struct 23 | { 24 | std::string name; 25 | } service; 26 | 27 | struct 28 | { 29 | OtelProcessorType type = OtelProcessorBatch; 30 | 31 | struct 32 | { 33 | uint32_t maxQueueSize = 2048; 34 | uint32_t maxExportBatchSize = 512; 35 | uint32_t scheduleDelayMillis = 5000; 36 | } batch; 37 | } processor; 38 | 39 | std::string sampler = "parentbased_always_on"; 40 | double samplerRatio = 1.0; 41 | }; 42 | -------------------------------------------------------------------------------- /exporters/user_events/include/opentelemetry/exporters/user_events/metrics/exporter_options.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "opentelemetry/version.h" 9 | 10 | OPENTELEMETRY_BEGIN_NAMESPACE 11 | namespace exporter 12 | { 13 | namespace user_events 14 | { 15 | namespace metrics 16 | { 17 | 18 | namespace sdk_metrics = opentelemetry::sdk::metrics; 19 | 20 | struct ExporterOptions 21 | { 22 | opentelemetry::exporter::otlp::PreferredAggregationTemporality aggregation_temporality = 23 | opentelemetry::exporter::otlp::PreferredAggregationTemporality::kCumulative; 24 | }; 25 | 26 | } // namespace metrics 27 | } // namespace user_events 28 | } // namespace exporter 29 | OPENTELEMETRY_END_NAMESPACE 30 | -------------------------------------------------------------------------------- /instrumentation/nginx/ci/setup_environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export DEBIAN_FRONTEND=noninteractive 4 | export TZ="Europe/London" 5 | 6 | apt-get install ca-certificates curl 7 | install -m 0755 -d /etc/apt/keyrings 8 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc 9 | chmod a+r /etc/apt/keyrings/docker.asc 10 | 11 | echo \ 12 | "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ 13 | $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ 14 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 15 | 16 | apt-get update 17 | apt-get install --no-install-recommends --no-install-suggests -y \ 18 | erlang elixir docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 19 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/generator/xcode_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2013 Google Inc. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """ Unit tests for the xcode.py file. """ 8 | 9 | import gyp.generator.xcode as xcode 10 | import unittest 11 | import sys 12 | 13 | 14 | class TestEscapeXcodeDefine(unittest.TestCase): 15 | if sys.platform == 'darwin': 16 | def test_InheritedRemainsUnescaped(self): 17 | self.assertEqual(xcode.EscapeXcodeDefine('$(inherited)'), '$(inherited)') 18 | 19 | def test_Escaping(self): 20 | self.assertEqual(xcode.EscapeXcodeDefine('a b"c\\'), 'a\\ b\\"c\\\\') 21 | 22 | if __name__ == '__main__': 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /exporters/geneva/build_tools/ports/opentelemetry-etw-metrics-exporter/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", 3 | "name": "opentelemetry-etw-metrics-exporter", 4 | "version-semver": "0.0.1", 5 | "description": [ 6 | "OpenTelemetry ETW Exporter uses OpenTelemetry API/SDK to export the metrics data to ETW." 7 | ], 8 | "homepage": "https://github.com/open-telemetry/opentelemetry-cpp-contrib", 9 | "license": "Apache-2.0", 10 | "dependencies": [ 11 | { 12 | "name": "opentelemetry-cpp", 13 | "host": true 14 | }, 15 | { 16 | "name": "vcpkg-cmake", 17 | "host": true 18 | }, 19 | { 20 | "name": "vcpkg-cmake-config", 21 | "host": true 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /exporters/user_events/include/opentelemetry/exporters/user_events/logs/utils.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "opentelemetry/sdk/common/attribute_utils.h" 7 | #include "opentelemetry/version.h" 8 | 9 | #include 10 | 11 | OPENTELEMETRY_BEGIN_NAMESPACE 12 | namespace exporter 13 | { 14 | namespace user_events 15 | { 16 | namespace utils 17 | { 18 | 19 | namespace api_common = opentelemetry::common; 20 | 21 | void PopulateAttribute(nostd::string_view key, 22 | const api_common::AttributeValue &value, 23 | ehd::EventBuilder &event_builder) noexcept; 24 | 25 | } // namespace utils 26 | } // namespace user_events 27 | } // namespace exporter 28 | OPENTELEMETRY_END_NAMESPACE -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/php/b3multi.php: -------------------------------------------------------------------------------- 1 | $b3_trace_id, 21 | "x-b3-spanid" => $b3_span_id, 22 | "x-b3-sampled" => $b3_sampled 23 | ))); 24 | ?> 25 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | git clone https://github.com/cisco-open/otel-webserver-module.git 5 | cp -r /dependencies /otel-webserver-module/ 6 | 7 | cp -r /build-dependencies /otel-webserver-module/ 8 | 9 | # change gradle script to include build-dependencies folder 10 | 11 | # Building the otel-webserver-module 12 | 13 | cd otel-webserver-module 14 | ./gradlew assembleApacheModule -PbuildType=debug 15 | 16 | #Changing the httpd.conf and Adding Opentelemetry.conf 17 | cd build 18 | tar -xf opentelemetry-webserver-sdk-x64-linux.tgz 19 | mv opentelemetry-webserver-sdk /opt/ 20 | cd ../ 21 | cp opentelemetry_module.conf /etc/httpd/conf.d/ 22 | 23 | # Installing 24 | 25 | cd /opt/opentelemetry-webserver-sdk 26 | ./install.sh 27 | 28 | # Runing Apache 29 | 30 | httpd 31 | curl localhost:80 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /exporters/geneva/cmake/ParseOsRelease.cmake: -------------------------------------------------------------------------------- 1 | # Parse /etc/os-release to determine Linux distro 2 | 3 | if(EXISTS /etc/os-release) 4 | file(STRINGS /etc/os-release OS_RELEASE) 5 | foreach(NameAndValue ${OS_RELEASE}) 6 | # Strip leading spaces 7 | string(REGEX REPLACE "^[ ]+" "" NameAndValue ${NameAndValue}) 8 | # Find variable name 9 | string(REGEX MATCH "^[^=]+" Name ${NameAndValue}) 10 | # Find the value 11 | string(REPLACE "${Name}=" "" Value ${NameAndValue}) 12 | # Strip quotes from value 13 | string(REPLACE "\"" "" Value ${Value}) 14 | # Set the variable 15 | message("-- /etc/os-release : ${Name}=${Value}") 16 | set("OS_RELEASE_${Name}" "${Value}") 17 | endforeach() 18 | else() 19 | set("OS_RELEASE_NAME" ${CMAKE_SYSTEM_NAME}) 20 | set("OS_RELEASE_ID" ${CMAKE_SYSTEM_NAME}) 21 | set("OS_RELEASE_VERSION_ID" "1.0") 22 | endif() -------------------------------------------------------------------------------- /instrumentation/httpd/setup-buildtools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export DEBIAN_FRONTEND=noninteractive 4 | apt-get update -y 5 | apt-get install -qq automake 6 | apt-get install -qq libtool-bin 7 | apt-get install -qq curl 8 | apt-get install -qq libcurl4-openssl-dev 9 | apt-get install -qq zlib1g-dev 10 | apt-get install -qq git 11 | apt-get install -qq build-essential 12 | apt-get install -qq libssl-dev 13 | apt-get install -qq libsqlite3-dev 14 | # Stock sqlite may be too old 15 | #apt install libsqlite3-dev 16 | apt-get install -qq wget 17 | 18 | # bazelisk is not in apt repository 19 | BAZELISK_VERSION=v1.7.4 20 | 21 | wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/$BAZELISK_VERSION/bazelisk-linux-amd64 22 | chmod +x /usr/local/bin/bazel 23 | 24 | 25 | ## Change owner from root to current dir owner 26 | chown -R `stat . -c %u:%g` * 27 | -------------------------------------------------------------------------------- /exporters/geneva-trace/tools/build-nuget.cmd: -------------------------------------------------------------------------------- 1 | Rem Copyright The OpenTelemetry Authors 2 | Rem SPDX-License-Identifier: Apache-2.0 3 | 4 | @echo off 5 | pushd "%~dp0" 6 | set "PATH=%CD%;%PATH%" 7 | 8 | if not defined PackageVersion ( 9 | echo "Set the PackageVersion before proceeding." 10 | exit 11 | ) 12 | if not exist "..\packages" mkdir "..\packages" 13 | 14 | REM This script assumes that the main OpenTelemetry C++ repo 15 | REM has been checked out as submodule 16 | powershell -File .\build-nuget.ps1 %CD%\..\third_party\opentelemetry-cpp 17 | 18 | REM If %OUTPUTROOT% variable is defined, then copy the packages 19 | REM to %OUTPUTROOT%\packages for subsequent deployment. 20 | if defined OUTPUTROOT ( 21 | if not exist "%OUTPUTROOT%\packages" mkdir "%OUTPUTROOT%\packages" 22 | copy /Y ..\packages\*.nupkg "%OUTPUTROOT%\packages" 23 | ) 24 | popd 25 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/unit/unit_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | int main(int argc, char **argv) { 19 | 20 | testing::InitGoogleTest(&argc, argv); 21 | 22 | return RUN_ALL_TESTS(); 23 | 24 | } -------------------------------------------------------------------------------- /instrumentation/httpd/Dockerfile.cmake: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | ######################################### 4 | # copy setup stuff from opentelemetry-cpp 5 | ######################################### 6 | 7 | WORKDIR /setup-ci 8 | 9 | ADD setup-buildtools.sh /setup-ci/setup-buildtools.sh 10 | 11 | RUN /setup-ci/setup-buildtools.sh 12 | 13 | ADD setup-environment.sh /setup/setup-environment.sh 14 | 15 | RUN /setup/setup-environment.sh 16 | 17 | COPY .clang-format /root 18 | 19 | WORKDIR /root 20 | 21 | # build with CMake 22 | COPY setup-cmake.sh . 23 | # RUN ls 24 | RUN /root/setup-cmake.sh 25 | 26 | COPY CMakeLists.txt /root 27 | COPY src /root/src 28 | 29 | RUN mkdir -p build \ 30 | && cd build \ 31 | && cmake .. \ 32 | && make -j2 33 | 34 | COPY tools /root/tools 35 | COPY create-otel-load.sh /root 36 | COPY opentelemetry.conf /root 37 | COPY httpd_install_otel.sh /root 38 | -------------------------------------------------------------------------------- /exporters/geneva/include/opentelemetry/exporters/geneva/metrics/exporter_options.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "opentelemetry/version.h" 9 | 10 | OPENTELEMETRY_BEGIN_NAMESPACE 11 | namespace exporter { 12 | namespace geneva { 13 | namespace metrics { 14 | 15 | struct ExporterOptions { 16 | // clang-format off 17 | /* 18 | Format - 19 | Windows: 20 | Account={MetricAccount};NameSpace={MetricNamespace} 21 | Linux: 22 | Endpoint=unix://{UDS Path};Account={MetricAccount};Namespace={MetricNamespace} 23 | */ 24 | // clang-format off 25 | std::string connection_string; 26 | const std::map prepopulated_dimensions; 27 | }; 28 | } // namespace metrics 29 | } // namespace geneva 30 | } // namespace exporter 31 | OPENTELEMETRY_END_NAMESPACE -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/tools/Xcode/Specifications/gyp.pbfilespec: -------------------------------------------------------------------------------- 1 | /* 2 | gyp.pbfilespec 3 | GYP source file spec for Xcode 3 4 | 5 | There is not much documentation available regarding the format 6 | of .pbfilespec files. As a starting point, see for instance the 7 | outdated documentation at: 8 | http://maxao.free.fr/xcode-plugin-interface/specifications.html 9 | and the files in: 10 | /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/ 11 | 12 | Place this file in directory: 13 | ~/Library/Application Support/Developer/Shared/Xcode/Specifications/ 14 | */ 15 | 16 | ( 17 | { 18 | Identifier = sourcecode.gyp; 19 | BasedOn = sourcecode; 20 | Name = "GYP Files"; 21 | Extensions = ("gyp", "gypi"); 22 | MIMETypes = ("text/gyp"); 23 | Language = "xcode.lang.gyp"; 24 | IsTextFile = YES; 25 | IsSourceFile = YES; 26 | } 27 | ) 28 | -------------------------------------------------------------------------------- /exporters/prometheus/src/push_exporter_factory.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2023, OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/exporters/prometheus/push_exporter_factory.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "opentelemetry/exporters/prometheus/push_exporter.h" 11 | #include "opentelemetry/exporters/prometheus/push_exporter_options.h" 12 | 13 | OPENTELEMETRY_BEGIN_NAMESPACE 14 | 15 | namespace exporter 16 | { 17 | namespace metrics 18 | { 19 | 20 | std::unique_ptr 21 | PrometheusPushExporterFactory::Create(const PrometheusPushExporterOptions &options) 22 | { 23 | return std::unique_ptr( 24 | new PrometheusPushExporter(options)); 25 | } 26 | 27 | } // namespace metrics 28 | } // namespace exporter 29 | OPENTELEMETRY_END_NAMESPACE 30 | -------------------------------------------------------------------------------- /exporters/prometheus/include/opentelemetry/exporters/prometheus/push_exporter_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023, OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #include "opentelemetry/sdk/metrics/push_metric_exporter.h" 9 | #include "opentelemetry/version.h" 10 | 11 | OPENTELEMETRY_BEGIN_NAMESPACE 12 | namespace exporter 13 | { 14 | namespace metrics 15 | { 16 | 17 | struct PrometheusPushExporterOptions; 18 | 19 | /** 20 | * Factory class for PrometheusExporter. 21 | */ 22 | class PrometheusPushExporterFactory 23 | { 24 | public: 25 | /** 26 | * Create a PrometheusExporter using the given options. 27 | */ 28 | static std::unique_ptr Create( 29 | const PrometheusPushExporterOptions &options); 30 | }; 31 | 32 | } // namespace metrics 33 | } // namespace exporter 34 | OPENTELEMETRY_END_NAMESPACE 35 | -------------------------------------------------------------------------------- /exporters/prometheus/include/opentelemetry/exporters/prometheus/push_exporter_options.h: -------------------------------------------------------------------------------- 1 | // Copyright 2023, OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "opentelemetry/version.h" 11 | 12 | OPENTELEMETRY_BEGIN_NAMESPACE 13 | namespace exporter 14 | { 15 | namespace metrics 16 | { 17 | 18 | /** 19 | * Struct to hold Prometheus exporter options. 20 | */ 21 | struct PrometheusPushExporterOptions 22 | { 23 | std::string host; 24 | std::string port; 25 | std::string jobname; 26 | std::unordered_map labels; 27 | std::string username; 28 | std::string password; 29 | 30 | std::size_t max_collection_size = 2000; 31 | 32 | inline PrometheusPushExporterOptions() noexcept {} 33 | }; 34 | 35 | } // namespace metrics 36 | } // namespace exporter 37 | OPENTELEMETRY_END_NAMESPACE 38 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/tools/README: -------------------------------------------------------------------------------- 1 | pretty_vcproj: 2 | Usage: pretty_vcproj.py "c:\path\to\vcproj.vcproj" [key1=value1] [key2=value2] 3 | 4 | They key/value pair are used to resolve vsprops name. 5 | 6 | For example, if I want to diff the base.vcproj project: 7 | 8 | pretty_vcproj.py z:\dev\src-chrome\src\base\build\base.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > orignal.txt 9 | pretty_vcproj.py z:\dev\src-chrome\src\base\base_gyp.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > gyp.txt 10 | 11 | And you can use your favorite diff tool to see the changes. 12 | 13 | Note: In the case of base.vcproj, the original vcproj is one level up the generated one. 14 | I suggest you do a search and replace for '"..\' and replace it with '"' in original.txt 15 | before you perform the diff. -------------------------------------------------------------------------------- /instrumentation/nginx/test/conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 2 | fastcgi_param SERVER_SOFTWARE nginx; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param REMOTE_ADDR $remote_addr; 14 | fastcgi_param REMOTE_PORT $remote_port; 15 | fastcgi_param SERVER_ADDR $server_addr; 16 | fastcgi_param SERVER_PORT $server_port; 17 | fastcgi_param SERVER_NAME $server_name; 18 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/unit/mocks/mock_dummy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include "Dummy.h" 18 | 19 | class MockMyAgentDep : public IAgentDep 20 | { 21 | public: 22 | MOCK_METHOD(std::string, FirstWork, (int arg)); 23 | MOCK_METHOD(bool, SecondWork, (const std::string& value)); 24 | }; -------------------------------------------------------------------------------- /instrumentation/nginx/config: -------------------------------------------------------------------------------- 1 | ngx_addon_name=otel_ngx_module 2 | ngx_module_type=HTTP 3 | ngx_module_name=$ngx_addon_name 4 | ngx_module_incs= 5 | ngx_module_deps=" \ 6 | $ngx_addon_dir/src/agent_config.h \ 7 | $ngx_addon_dir/src/location_config.h \ 8 | $ngx_addon_dir/src/nginx_config.h \ 9 | $ngx_addon_dir/src/nginx_utils.h \ 10 | $ngx_addon_dir/src/propagate.h \ 11 | $ngx_addon_dir/src/script.h \ 12 | $ngx_addon_dir/src/trace_context.h \ 13 | " 14 | ngx_module_srcs=" \ 15 | $ngx_addon_dir/src/nginx_config.cpp \ 16 | $ngx_addon_dir/src/otel_ngx_module.cpp \ 17 | $ngx_addon_dir/src/propagate.cpp \ 18 | $ngx_addon_dir/src/script.cpp \ 19 | $ngx_addon_dir/src/trace_context.cpp \ 20 | " 21 | ngx_module_libs=" \ 22 | -lstdc++ \ 23 | -lopentelemetry_common \ 24 | -lopentelemetry_resources \ 25 | -lopentelemetry_trace \ 26 | -lopentelemetry_exporter_otlp_http \ 27 | -lopentelemetry_otlp_recordable \ 28 | " 29 | 30 | . auto/module 31 | -------------------------------------------------------------------------------- /instrumentation/httpd/create-otel-load.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | POSSIBLE_BUILD_OUTPUT=() 6 | POSSIBLE_BUILD_OUTPUT+=("${SCRIPT_DIR}/bazel-out/k8-opt/bin/otel.so") # when build was done with Bazel 7 | POSSIBLE_BUILD_OUTPUT+=("${SCRIPT_DIR}/build/otel_httpd_module.so") # when build was done with CMake 8 | 9 | for LOCATE_OUTPUT in "${POSSIBLE_BUILD_OUTPUT[@]}"; do 10 | if [ -f ${LOCATE_OUTPUT} ]; then 11 | FOUND=${LOCATE_OUTPUT} 12 | echo Found file ${FOUND} 13 | break 14 | fi 15 | done 16 | 17 | if [ -z ${FOUND+x} ]; then 18 | echo "Binary module not found!" 19 | echo "Please run make build-cmake or make build-bazel first" 20 | exit 1 21 | fi 22 | 23 | # create configuration file for httpd (Apache) 24 | cat << EOF > opentelemetry.load 25 | # C++ Standard library 26 | LoadFile /usr/lib/x86_64-linux-gnu/libstdc++.so.6 27 | 28 | LoadModule otel_module $FOUND 29 | EOF 30 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/location_config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "trace_context.h" 4 | #include "script.h" 5 | 6 | extern "C" { 7 | extern ngx_module_t otel_ngx_module; 8 | } 9 | 10 | struct OtelNgxLocationConf { 11 | ngx_flag_t enabled = NGX_CONF_UNSET; 12 | ngx_flag_t trustIncomingSpans = NGX_CONF_UNSET; 13 | ngx_flag_t captureHeaders = NGX_CONF_UNSET; 14 | #if (NGX_PCRE) 15 | ngx_regex_t *sensitiveHeaderNames = (ngx_regex_t*)NGX_CONF_UNSET_PTR; 16 | ngx_regex_t *sensitiveHeaderValues = (ngx_regex_t*)NGX_CONF_UNSET_PTR; 17 | ngx_regex_t *ignore_paths = (ngx_regex_t*)NGX_CONF_UNSET_PTR; 18 | #endif 19 | TracePropagationType propagationType = TracePropagationUnset; 20 | NgxCompiledScript operationNameScript; 21 | ngx_array_t* customAttributes = nullptr; 22 | }; 23 | 24 | inline OtelNgxLocationConf* GetOtelLocationConf(ngx_http_request_t* req) { 25 | return (OtelNgxLocationConf*)ngx_http_get_module_loc_conf(req, otel_ngx_module); 26 | } 27 | -------------------------------------------------------------------------------- /instrumentation/httpd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | ######################################### 4 | # copy setup stuff from opentelemetry-cpp 5 | ######################################### 6 | 7 | WORKDIR /setup-ci 8 | 9 | ADD setup-buildtools.sh /setup-ci/setup-buildtools.sh 10 | 11 | RUN /setup-ci/setup-buildtools.sh 12 | 13 | ######################### 14 | # now build plugin itself 15 | ######################### 16 | 17 | ADD setup-environment.sh /setup/setup-environment.sh 18 | 19 | RUN /setup/setup-environment.sh 20 | 21 | COPY src /root/src 22 | COPY .clang-format /root 23 | COPY tools /root/tools 24 | 25 | COPY .bazelversion /root 26 | COPY BUILD /root 27 | COPY WORKSPACE /root 28 | 29 | WORKDIR /root 30 | COPY create-otel-load.sh /root 31 | COPY build.sh /root 32 | COPY opentelemetry.conf /root 33 | COPY httpd_install_otel.sh /root 34 | RUN /root/build.sh 35 | 36 | # TODO: check apache configuration (apachectl configtest) 37 | 38 | # TODO: run tests? 39 | -------------------------------------------------------------------------------- /exporters/fluentd/include/opentelemetry/exporters/fluentd/common/fluentd_logging.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #if defined(HAVE_CONSOLE_LOG) && !defined(LOG_DEBUG) 5 | // Log to console if there's no standard log facility defined 6 | #include 7 | #ifndef LOG_DEBUG 8 | #define LOG_DEBUG(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 9 | #define LOG_TRACE(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 10 | #define LOG_INFO(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 11 | #define LOG_WARN(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 12 | #define LOG_ERROR(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 13 | #endif 14 | #endif 15 | 16 | #ifndef LOG_DEBUG 17 | // Don't log anything if there's no standard log facility defined 18 | #define LOG_DEBUG(fmt_, ...) 19 | #define LOG_TRACE(fmt_, ...) 20 | #define LOG_INFO(fmt_, ...) 21 | #define LOG_WARN(fmt_, ...) 22 | #define LOG_ERROR(fmt_, ...) 23 | #endif 24 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/05-check-batch-spans.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that 5 requests creates 5 spans (with batch)" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | OpenTelemetryExporter file 11 | OpenTelemetryPath ${OUTPUT_SPANS} 12 | OpenTelemetryBatch 10 5000 5 13 | EOF 14 | 15 | } 16 | 17 | run_test() { 18 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page (1/5)" 19 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page (2/5)" 20 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page (3/5)" 21 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page (4/5)" 22 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page (5/5)" 23 | } 24 | 25 | check_results() { 26 | echo Checking that all ${TOTAL_SPANS} were created 27 | count '{' 5 # span count is good 28 | } 29 | 30 | teardown_test() { 31 | rm -rf ${OUTPUT_SPANS} 32 | } 33 | 34 | run $@ 35 | -------------------------------------------------------------------------------- /instrumentation/httpd/tools/format-bazel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # directory one level up from this script directory 4 | PROJECT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd ) 5 | 6 | if ! ${BUILDIFIER:=buildifier} -version ; then 7 | echo ${BUILDIFIER} not found in '$PATH' = $PATH >&2 8 | exit 1 9 | fi 10 | 11 | 12 | if [ "$1" == "-i" ]; then # apply 13 | MODE="-mode fix -v" 14 | shift 15 | else 16 | MODE="-mode diff" 17 | fi 18 | 19 | if [[ "$#" -gt 0 && -d "$1" ]]; then 20 | PROJECT_DIR="$1" 21 | shift 22 | fi 23 | 24 | SRC_FILES=${1:-$(find "$PROJECT_DIR" -path '*/.*' -prune -name WORKSPACE -print -o -name BUILD -print -o \ 25 | -name '*.BUILD' -o -name '*.bzl' -print)} 26 | 27 | ${BUILDIFIER} ${MODE} ${SRC_FILES} 28 | 29 | BADFORMAT=$? 30 | if [ "$BADFORMAT" != "0" ]; then 31 | echo >&2 32 | echo "There are some files with broken formating, please run following command to fix all of them:" >&2 33 | echo "$0 -i" >&2 34 | exit 1 35 | fi 36 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/conf/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | user nginx; 3 | worker_processes 1; 4 | 5 | error_log /var/log/nginx/error.log warn; 6 | pid /var/run/nginx.pid; 7 | 8 | load_module /opt/opentelemetry-webserver-sdk/WebServerModule/Nginx/ngx_http_opentelemetry_module.so; 9 | 10 | events { 11 | worker_connections 1024; 12 | } 13 | 14 | 15 | http { 16 | include /etc/nginx/mime.types; 17 | default_type application/octet-stream; 18 | 19 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 20 | '$status $body_bytes_sent "$http_referer" ' 21 | '"$http_user_agent" "$http_x_forwarded_for"'; 22 | 23 | access_log /var/log/nginx/access.log main; 24 | 25 | sendfile on; 26 | #tcp_nopush on; 27 | 28 | keepalive_timeout 65; 29 | 30 | #gzip on; 31 | 32 | include /etc/nginx/conf.d/*.conf; 33 | include /opt/opentelemetry_module.conf; 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/geneva_trace.yml: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | name: Geneva Trace Nuget Generation 5 | 6 | on: 7 | push: 8 | branches: "*" 9 | paths: 10 | - "exporters/geneva-trace/**" 11 | - ".github/workflows/geneva_trace.yml" 12 | pull_request: 13 | branches: [main] 14 | paths: 15 | - "exporters/geneva-trace/**" 16 | - ".github/workflows/geneva_trace.yml" 17 | 18 | permissions: 19 | contents: read 20 | 21 | jobs: 22 | geneva-trace-nuget-generation: 23 | name: Geneva Trace 24 | runs-on: windows-latest 25 | steps: 26 | - name: github config 27 | run: git config --system core.longpaths true 28 | - uses: actions/checkout@v6.0.1 29 | with: 30 | submodules: 'recursive' 31 | - name: NuGet package generation 32 | env: 33 | PackageVersion: 0.0.1 34 | run: | 35 | cd exporters\geneva-trace\tools && .\build-nuget.cmd 36 | -------------------------------------------------------------------------------- /exporters/fluentd/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## Guideline to update the version 9 | 10 | Increment the: 11 | 12 | * MAJOR version when you make incompatible API/ABI changes, 13 | * MINOR version when you add functionality in a backwards compatible manner, and 14 | * PATCH version when you make backwards compatible bug fixes. 15 | 16 | ## [2.0.0] 2023-06-30 17 | 18 | * [EXPORTER] OpenTelemetry SDK v1.9.1 compatibility. Migrate to ObservedTimestamp from Timestamp. 19 | 20 | ## [1.2.0] 2022-08-29 21 | 22 | * [EXPORTER] OpenTelemetry SDK v1.6.0 compatibility 23 | 24 | ## [1.1.2] 2022-06-30 25 | 26 | * [EXPORTER] OpenTelemetry SDK v1.4.0 compatibility 27 | 28 | ## [1.1.1] 2022-03-16 29 | 30 | * [EXPORTER] OpenTelemetry SDK v1.1.1 compatibility 31 | 32 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/03-accept-inbound-b3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that incoming span is accepted with b3 format (same trace_id and parent_span_id are set)" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | OpenTelemetryExporter file 11 | OpenTelemetryPath ${OUTPUT_SPANS} 12 | OpenTelemetryPropagators b3 13 | OpenTelemetryIgnoreInbound Off 14 | EOF 15 | 16 | } 17 | 18 | TRACE_ID="0abcdefabcdefabcdefabcdefabcdef0" 19 | TRACE_PARENT="0123456789abcdef" 20 | TRACE_FLAGS="1" 21 | 22 | HEADER="b3: ${TRACE_ID}-${TRACE_PARENT}-${TRACE_FLAGS}" 23 | 24 | run_test() { 25 | ${CURL_CMD} -H "${HEADER}" ${ENDPOINT_URL} || fail "Unable to download main page" 26 | } 27 | 28 | check_results() { 29 | echo Checking that exactly one span was created 30 | count '{' 1 # total one span 31 | 32 | echo "Checking that trace_id and span_id was properly parsed" 33 | check 'trace_id' ${TRACE_ID} 34 | check 'parent_span_id' ${TRACE_PARENT} 35 | } 36 | 37 | run $@ 38 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/conf/nginx/opentelemetry_module.conf: -------------------------------------------------------------------------------- 1 | NginxModuleEnabled ON; 2 | #NginxModule Otel Exporter details 3 | NginxModuleOtelSpanExporter otlp; 4 | NginxModuleOtelExporterEndpoint docker.for.mac.localhost:4317; 5 | #NginxModuleOtelExporterOtlpHeaders Authorization=AuthorizationToken; 6 | # SSL Certificates 7 | #NginxModuleOtelSslEnabled ON 8 | #NginxModuleOtelSslCertificatePath 9 | #NginxModuleOtelSpanProcessor Batch 10 | #NginxModuleOtelSampler AlwaysOn 11 | #NginxModuleOtelMaxQueueSize 1024 12 | #NginxModuleOtelScheduledDelayMillis 3000 13 | #NginxModuleOtelExportTimeoutMillis 30000 14 | #NginxModuleOtelMaxExportBatchSize 1024 15 | NginxModuleServiceName DemoService; 16 | NginxModuleServiceNamespace DemoServiceNamespace; 17 | NginxModuleServiceInstanceId DemoInstanceId; 18 | NginxModuleResolveBackends ON; 19 | NginxModuleTraceAsError ON; 20 | #NginxModuleWebserverContext DemoService DemoServiceNamespace DemoInstanceId 21 | #NginxModuleSegmentType custom 22 | #NginxModuleSegmentParameter 15,1,6,7 -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/core/sdkwrapper/SdkEnums.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace otel { 20 | namespace core { 21 | namespace sdkwrapper { 22 | 23 | enum class StatusCode { 24 | Ok, 25 | Error, 26 | Unset 27 | }; 28 | 29 | enum class SpanKind { 30 | INTERNAL, 31 | SERVER, 32 | CLIENT 33 | }; 34 | 35 | } // sdkwrapper 36 | } // core 37 | } // otel 38 | -------------------------------------------------------------------------------- /exporters/geneva-trace/tools/nuget/README.md: -------------------------------------------------------------------------------- 1 | # NuGet package creation process 2 | 3 | This directory contains NuGet specification files (.nuspec). 4 | 5 | Creating nuget packages: 6 | 7 | - Set `PackageVersion` environment variable that defines the package version. 8 | 9 | ```console 10 | set PackageVersion=0.4.0 11 | ``` 12 | 13 | - Run `tools/build-nuget.cmd` script to create the package(s). Packages are copied to `.\packages` 14 | directory. 15 | 16 | - Push selected package to nuget feed using `NuGet.exe` tool. 17 | 18 | Learn more about native code NuGet packages [here](https://docs.microsoft.com/en-us/nuget/guides/native-packages). 19 | 20 | ## NuGet package flavors 21 | 22 | The following packages created : 23 | 24 | | Package Name | Desription | Notes | 25 | |------------------------------|-------------------------------------------------------------|-------| 26 | | OpenTelemetry.Cpp.Geneva | OpenTelemetry C++ SDK with Geneva Exporter in one package | | 27 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/02-accept-inbound-trace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that incoming span is accepted (same trace_id and parent_span_id are set)" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | OpenTelemetryExporter file 11 | OpenTelemetryPath ${OUTPUT_SPANS} 12 | OpenTelemetryPropagators trace-context 13 | OpenTelemetryIgnoreInbound Off 14 | EOF 15 | 16 | } 17 | 18 | TRACE_VER="00" 19 | TRACE_ID="00112233445566778899aabbccddeeff" 20 | TRACE_PARENT="0101010101010101" 21 | TRACE_FLAGS="01" 22 | 23 | HEADER="traceparent: ${TRACE_VER}-${TRACE_ID}-${TRACE_PARENT}-${TRACE_FLAGS}" 24 | 25 | run_test() { 26 | ${CURL_CMD} -H "${HEADER}" ${ENDPOINT_URL} || fail "Unable to download main page" 27 | } 28 | 29 | check_results() { 30 | echo Checking that exactly one span was created 31 | count '{' 1 # total one span 32 | 33 | echo "Checking that trace_id and span_id was properly parsed" 34 | check 'trace_id' ${TRACE_ID} 35 | check 'parent_span_id' ${TRACE_PARENT} 36 | } 37 | 38 | run $@ 39 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/04-accept-inbound-b3-multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that incoming span is accepted with b3 multiline header (same trace_id and parent_span_id are set)" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | OpenTelemetryExporter file 11 | OpenTelemetryPath ${OUTPUT_SPANS} 12 | OpenTelemetryPropagators b3-multiheader 13 | OpenTelemetryIgnoreInbound Off 14 | EOF 15 | 16 | } 17 | 18 | TRACE_ID="00abba0000abba0000abba0000abba00" 19 | TRACE_PARENT="aabbaabbaabbaabb" 20 | 21 | HEADER_1="X-B3-TraceId: ${TRACE_ID}" 22 | HEADER_2="X-B3-SpanId: ${TRACE_PARENT}" 23 | 24 | run_test() { 25 | ${CURL_CMD} -H "${HEADER_1}" -H "${HEADER_2}" ${ENDPOINT_URL} || fail "Unable to download main page" 26 | } 27 | 28 | check_results() { 29 | echo Checking that exactly one span was created 30 | count '{' 1 # total one span 31 | 32 | echo "Checking that trace_id and span_id was properly parsed" 33 | check 'trace_id' ${TRACE_ID} 34 | check 'parent_span_id' ${TRACE_PARENT} 35 | } 36 | 37 | run $@ 38 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/trace_context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern "C" { 6 | #include 7 | } 8 | 9 | struct TraceHeader { 10 | ngx_str_t key = ngx_null_string; 11 | ngx_str_t value = ngx_null_string; 12 | }; 13 | 14 | enum TracePropagationType { 15 | TracePropagationUnset, 16 | TracePropagationW3C, 17 | TracePropagationB3, 18 | TracePropagationB3Multi, 19 | }; 20 | 21 | struct TraceContext { 22 | TraceContext(ngx_http_request_t* req) : request(req), traceHeader{} {} 23 | /* The current request being handled by nginx. */ 24 | ngx_http_request_t* request; 25 | opentelemetry::nostd::shared_ptr request_span; 26 | /* Headers to be injected for the upstream request. */ 27 | TraceHeader traceHeader[2]; 28 | }; 29 | 30 | bool TraceContextSetTraceHeader( 31 | TraceContext* context, opentelemetry::nostd::string_view key, 32 | opentelemetry::nostd::string_view value); 33 | 34 | const TraceHeader* 35 | TraceContextFindTraceHeader(const TraceContext* context, opentelemetry::nostd::string_view key); 36 | -------------------------------------------------------------------------------- /instrumentation/httpd/tools/setup-tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | BUILDIFIER_VERSION=3.5.0 4 | 5 | ARGS="${1:-code build}" 6 | 7 | print_help () { 8 | echo "Installs tools for checking code formatting" 9 | echo "$0 [code] [build]" 10 | } 11 | 12 | setup_clang () { 13 | export DEBIAN_FRONTEND=noninteractive 14 | apt-get update -y 15 | apt-get install -qq git 16 | apt-get install -qq clang-format 17 | } 18 | 19 | setup_buildifier () { 20 | apt-get install -qq curl 21 | curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/${BUILDIFIER_VERSION}/buildifier 22 | chmod +x /usr/local/bin/buildifier 23 | } 24 | 25 | setup_all () { 26 | while [[ $# > 0 ]] ; do case "$1" in 27 | code|clang) 28 | setup_clang 29 | shift 30 | ;; 31 | build|buildifier) 32 | setup_buildifier 33 | shift 34 | ;; 35 | -h) 36 | print_help 37 | exit 0 38 | ;; 39 | *) 40 | print_help 41 | echo "Unknown argument: $1" >&2 42 | exit 1 43 | ;; 44 | esac done 45 | } 46 | 47 | setup_all ${ARGS} 48 | -------------------------------------------------------------------------------- /exporters/user_events/test/logs_exporter_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "opentelemetry/exporters/user_events/logs/exporter.h" 10 | 11 | #include 12 | 13 | namespace sdk_logs = opentelemetry::sdk::logs; 14 | namespace user_events_logs = opentelemetry::exporter::user_events::logs; 15 | 16 | // Test that when OStream Log exporter is shutdown, no logs should be sent to stream 17 | TEST(UserEventsLogRecordExporter, Shutdown) 18 | { 19 | auto options = user_events_logs::ExporterOptions(); 20 | auto exporter = 21 | std::unique_ptr(new user_events_logs::Exporter(options)); 22 | 23 | // Save cout's original buffer here 24 | std::streambuf *original = std::cout.rdbuf(); 25 | 26 | // Redirect cout to our stringstream buffer 27 | std::stringstream output; 28 | std::cout.rdbuf(output.rdbuf()); 29 | 30 | EXPECT_TRUE(exporter->Shutdown()); 31 | 32 | std::cout.rdbuf(original); 33 | } 34 | -------------------------------------------------------------------------------- /exporters/fluentd/example/trace/foo_library/foo_library.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/trace/provider.h" 5 | 6 | namespace trace = opentelemetry::trace; 7 | namespace nostd = opentelemetry::nostd; 8 | 9 | namespace { 10 | nostd::shared_ptr get_tracer() { 11 | auto provider = trace::Provider::GetTracerProvider(); 12 | return provider->GetTracer("foo_library"); 13 | } 14 | 15 | void f1() { 16 | auto span = get_tracer()->StartSpan("f1"); 17 | span->AddEvent("f1_even1", {{"k1", "v1"}}); 18 | span->SetAttribute("attribute_key", "attribute_value"); 19 | auto scope = get_tracer()->WithActiveSpan(span); 20 | span->End(); 21 | } 22 | 23 | void f2() { 24 | auto span = get_tracer()->StartSpan("f2"); 25 | auto scope = get_tracer()->WithActiveSpan(span); 26 | 27 | f1(); 28 | f1(); 29 | span->End(); 30 | } 31 | } // namespace 32 | 33 | void foo_library() { 34 | auto span = get_tracer()->StartSpan("library"); 35 | auto scope = get_tracer()->WithActiveSpan(span); 36 | 37 | f2(); 38 | 39 | span->End(); 40 | } 41 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/otel-config.yml: -------------------------------------------------------------------------------- 1 | processors: 2 | resource: 3 | attributes: 4 | - key: cloud.zone 5 | value: "zone-1" 6 | action: upsert 7 | - key: host.name 8 | value: "sample-container" 9 | action: upsert 10 | - key: service.namespace 11 | value: "sample_namespace" 12 | action: upsert 13 | # - key: service.name 14 | # value: "sample_service" 15 | # action: upsert 16 | receivers: 17 | otlp: 18 | protocols: 19 | grpc: 20 | http: 21 | zipkin: 22 | exporters: 23 | debug: 24 | verbosity: detailed 25 | zipkin: 26 | endpoint: "http://zipkin:9411/api/v2/spans" 27 | format: proto 28 | 29 | service: 30 | pipelines: 31 | traces: 32 | receivers: [otlp, zipkin] 33 | exporters: [debug, zipkin] 34 | processors: [resource] 35 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/unit/mocks/mock_SdkHelperFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef __MOCKSDKHELPERFACTORY_H 17 | #define __MOCKSDKHELPERFACTORY_H 18 | 19 | #include 20 | #include "sdkwrapper/ISdkHelperFactory.h" 21 | 22 | class MockSdkHelperFactory : public otel::core::sdkwrapper::ISdkHelperFactory 23 | { 24 | public: 25 | MOCK_METHOD(otel::core::OtelTracer, GetTracer, (), (override)); 26 | MOCK_METHOD(otel::core::OtelPropagators&, GetPropagators, (), (override)); 27 | }; 28 | #endif -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/gradle/conf/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | labels: bug, general 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/geneva.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: geneva 3 | about: Issues related to exporters/geneva 4 | labels: exporter:geneva 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /instrumentation/httpd/WORKSPACE: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | 3 | # Load OpentTelemetry-CPP dependency 4 | http_archive( 5 | name = "io_opentelemetry_cpp", 6 | sha256 = "59e16eab4f534907144882fe70a1ca4514cf720f7b8b6e2a2d999a1b1a9265c8", 7 | strip_prefix = "opentelemetry-cpp-b4584adeaae259df89b33af884c641e70a60a7cf", 8 | urls = [ 9 | "https://github.com/open-telemetry/opentelemetry-cpp/archive/b4584adeaae259df89b33af884c641e70a60a7cf.tar.gz" 10 | ], 11 | ) 12 | 13 | # Load OpenTelemetry dependencies after load. 14 | load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps") 15 | 16 | opentelemetry_cpp_deps() 17 | 18 | # Load gRPC dependencies after load. 19 | load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") 20 | 21 | grpc_deps() 22 | 23 | # Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 24 | load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") 25 | 26 | grpc_extra_deps() 27 | 28 | load("@upb//bazel:repository_defs.bzl", "bazel_version_repository") 29 | 30 | bazel_version_repository(name = "upb_bazel_version") 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/fluentd.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: fluentd 3 | about: Issues related to exporters/fluentd 4 | labels: exporter:fluentd 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/glog.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: glog 3 | about: Issues related to instrumentation/glog 4 | labels: instrumentation:glog 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/httpd.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: httpd 3 | about: Issues related to instrumentation/httpd 4 | labels: instrumentation:httpd 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/nginx.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: nginx 3 | about: Issues related to instrumentation/nginx 4 | labels: instrumentation:nginx 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/spdlog.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: spdlog 3 | about: Issues related to instrumentation/spdlog 4 | labels: instrumentation:spdlog 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/boost_log.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: boost_log 3 | about: Issues related to instrumentation/boost_log 4 | labels: instrumentation:boost-log 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/log4cxx.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: log4cxx 3 | about: Issues related to instrumentation/log4cxx 4 | labels: instrumentation:log4cxx 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/prometheus.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: prometheus 3 | about: Issues related to exporters/prometheus 4 | labels: exporter:prometheus 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/user_events.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: user_events 3 | about: Issues related to exporters/user_events 4 | labels: exporter:user_events 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/geneva-trace.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: geneva-trace 3 | about: Issues related to exporters/geneva-trace 4 | labels: exporter:geneva-trace 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /instrumentation/glog/include/opentelemetry/instrumentation/glog/sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace google 13 | { 14 | 15 | class OpenTelemetrySink : public google::LogSink 16 | { 17 | public: 18 | static inline opentelemetry::logs::Severity levelToSeverity(int level) noexcept 19 | { 20 | using opentelemetry::logs::Severity; 21 | 22 | switch (level) 23 | { 24 | case google::GLOG_FATAL: 25 | return Severity::kFatal; 26 | case google::GLOG_ERROR: 27 | return Severity::kError; 28 | case google::GLOG_WARNING: 29 | return Severity::kWarn; 30 | case google::GLOG_INFO: 31 | return Severity::kInfo; 32 | default: 33 | return Severity::kInvalid; 34 | } 35 | } 36 | 37 | void send(google::LogSeverity, 38 | const char *, 39 | const char *, 40 | int, 41 | const google::LogMessageTime &, 42 | const char *, 43 | size_t) override; 44 | }; 45 | 46 | } // namespace google 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/otel-webserver-module.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: otel-webserver-module 3 | about: Issues related to instrumentation/otel-webserver-module 4 | labels: Webserver 5 | --- 6 | 7 | **Describe your environment** Describe any aspect of your environment relevant to the problem, including your platform, build system, version numbers of installed dependencies, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on main branch. 8 | 9 | **Steps to reproduce** 10 | Describe exactly how to reproduce the error. Include a code sample if applicable. 11 | 12 | **What is the expected behavior?** 13 | What did you expect to see? 14 | 15 | **What is the actual behavior?** 16 | What did you see instead? 17 | 18 | **Additional context** 19 | Add any other context about the problem here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | 23 | -------------------------------------------------------------------------------- /exporters/user_events/include/opentelemetry/exporters/user_events/logs/exporter_options.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include "opentelemetry/version.h" 8 | 9 | OPENTELEMETRY_BEGIN_NAMESPACE 10 | namespace exporter 11 | { 12 | namespace user_events 13 | { 14 | namespace logs 15 | { 16 | 17 | const std::string kDefaultUserEventsLogsProviderName = "opentelemetry_logs"; 18 | 19 | /** 20 | * Struct to hold the options needed for the user_events logs exporter. 21 | */ 22 | 23 | struct ExporterOptions 24 | { 25 | public: 26 | ExporterOptions() : ExporterOptions(kDefaultUserEventsLogsProviderName) {} 27 | 28 | ExporterOptions(std::string provider_name) 29 | { 30 | if (provider_name.empty()) 31 | { 32 | this->provider_name = kDefaultUserEventsLogsProviderName; 33 | } 34 | else 35 | { 36 | this->provider_name = provider_name; 37 | } 38 | } 39 | 40 | public: 41 | std::string provider_name; 42 | }; 43 | 44 | } // namespace logs 45 | } // namespace user_events 46 | } // namespace exporter 47 | OPENTELEMETRY_END_NAMESPACE 48 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | To log Agent logs into NGINX error logs, 25 | based on the flag "NginxModuleTraceAsError" set by user 26 | */ 27 | ngx_flag_t logState; // read the value of "NginxModuleTraceAsError" flag 28 | void ngx_writeTrace(ngx_log_t *log, const char* funcName, const char* note, ...); 29 | void ngx_writeError(ngx_log_t *log, const char* funcName, const char* note, ...); 30 | -------------------------------------------------------------------------------- /exporters/fluentd/example/fluentd-docker/fluent.conf: -------------------------------------------------------------------------------- 1 | #### 2 | ## Output descriptions: 3 | ## 4 | 5 | ## match tag=debug.** and dump to console 6 | 7 | @type stdout 8 | @id output_stdout 9 | 10 | 11 | #### 12 | ## Source descriptions: 13 | ## 14 | # Concurrent ingestion of OpenTelemetry logs and traces requires more than one system worker thread. 15 | 16 | workers 3 17 | 18 | 19 | ## built-in TCP input 20 | ## @see http://docs.fluentd.org/articles/in_forward 21 | 22 | @type forward 23 | @id input_forward 24 | bind 0.0.0.0 25 | port 24222 26 | 27 | 28 | ## built-in UNIX socket input 29 | # Uncomment for Unix Domain socket support 30 | # 31 | # @type unix 32 | # path /tmp/fluentd/log/socket.sock 33 | # 34 | 35 | # HTTP input 36 | # POST http://localhost:8888/?json= 37 | # POST http://localhost:8888/td.myapp.login?json={"user"%3A"me"} 38 | # @see http://docs.fluentd.org/articles/in_http 39 | 40 | @type http 41 | @id input_http 42 | port 8888 43 | 44 | 45 | ## live debugging agent 46 | 47 | @type debug_agent 48 | @id input_debug_agent 49 | bind 0.0.0.0 50 | port 24230 51 | 52 | -------------------------------------------------------------------------------- /instrumentation/httpd/tools/format-code.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # directory one level up from this script directory 4 | PROJECT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd ) 5 | 6 | APPLY="" 7 | 8 | if [ "$1" == "-i" ]; then # apply 9 | APPLY="-i" 10 | shift 11 | fi 12 | 13 | if [[ "$#" -gt 0 && -d "$1" ]]; then 14 | PROJECT_DIR="$1" 15 | shift 16 | fi 17 | 18 | SRC_FILES=${1:-$(find "$PROJECT_DIR" -path '.*' -prune -name '*.c*' -o -name '*.h')} 19 | 20 | if ! ${CLANG_FORMAT:=clang-format} --version ; then 21 | echo ${CLANG_FORMAT} not found in '$PATH' = $PATH >&2 22 | exit 1 23 | fi 24 | 25 | if [ "$APPLY" == "-i" ]; then 26 | ${CLANG_FORMAT} --verbose --style=file -i ${SRC_FILES} 27 | exit $? 28 | fi 29 | 30 | # show formatting problems 31 | EXITCODE=0 32 | for FILE in $SRC_FILES; do 33 | ${CLANG_FORMAT} --style=file "${FILE}" | git diff --no-index -- "${FILE}" - 34 | BADFORMAT=$? 35 | if [ "$BADFORMAT" != "0" ]; then 36 | EXITCODE=1 37 | fi 38 | done 39 | 40 | if [ "$EXITCODE" != "0" ]; then 41 | echo >&2 42 | echo "There are some files with broken formating, please run following command to fix all of them:" >&2 43 | echo "$0 -i" >&2 44 | fi 45 | 46 | exit ${EXITCODE} 47 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/generator/msvs_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 2012 Google Inc. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """ Unit tests for the msvs.py file. """ 7 | 8 | import gyp.generator.msvs as msvs 9 | import unittest 10 | import StringIO 11 | 12 | 13 | class TestSequenceFunctions(unittest.TestCase): 14 | 15 | def setUp(self): 16 | self.stderr = StringIO.StringIO() 17 | 18 | def test_GetLibraries(self): 19 | self.assertEqual( 20 | msvs._GetLibraries({}), 21 | []) 22 | self.assertEqual( 23 | msvs._GetLibraries({'libraries': []}), 24 | []) 25 | self.assertEqual( 26 | msvs._GetLibraries({'other':'foo', 'libraries': ['a.lib']}), 27 | ['a.lib']) 28 | self.assertEqual( 29 | msvs._GetLibraries({'libraries': ['-la']}), 30 | ['a.lib']) 31 | self.assertEqual( 32 | msvs._GetLibraries({'libraries': ['a.lib', 'b.lib', 'c.lib', '-lb.lib', 33 | '-lb.lib', 'd.lib', 'a.lib']}), 34 | ['c.lib', 'b.lib', 'd.lib', 'a.lib']) 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | labels: feature-request 5 | --- 6 | 7 | Before opening a feature request against this repo, consider whether the feature should/could be implemented in the [other OpenTelemetry client libraries](https://github.com/open-telemetry/). If so, please [open an issue on opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification/issues/new) first. 8 | 9 | **Is your feature request related to a problem?** 10 | If so, provide a concise description of the problem. 11 | 12 | **Describe the solution you'd like** 13 | What do you want to happen instead? What is the expected behavior? 14 | 15 | **Describe alternatives you've considered** 16 | Which alternative solutions or features have you considered? 17 | 18 | **Additional context** 19 | Add any other context about the feature request here. 20 | 21 | **Tip**: [React](https://github.blog/news-insights/product-news/add-reactions-to-pull-requests-issues-and-comments/) with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it. Learn more [here](https://opentelemetry.io/community/end-user/issue-participation/). 22 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/script.cpp: -------------------------------------------------------------------------------- 1 | #include "script.h" 2 | 3 | bool CompileScript(ngx_conf_t* conf, ngx_str_t pattern, NgxCompiledScript* script) { 4 | script->pattern = pattern; 5 | script->lengths = nullptr; 6 | script->values = nullptr; 7 | 8 | ngx_uint_t numVariables = ngx_http_script_variables_count(&script->pattern); 9 | 10 | if (numVariables == 0) { 11 | return true; 12 | } 13 | 14 | ngx_http_script_compile_t compilation; 15 | ngx_memzero(&compilation, sizeof(compilation)); 16 | compilation.cf = conf; 17 | compilation.source = &script->pattern; 18 | compilation.lengths = &script->lengths; 19 | compilation.values = &script->values; 20 | compilation.variables = numVariables; 21 | compilation.complete_lengths = 1; 22 | compilation.complete_values = 1; 23 | 24 | return ngx_http_script_compile(&compilation) == NGX_OK; 25 | } 26 | 27 | bool CompileScriptAttribute( 28 | ngx_conf_t* conf, ScriptAttributeDeclaration declaration, 29 | CompiledScriptAttribute* compiledAttribute) { 30 | compiledAttribute->type = declaration.type; 31 | 32 | if (!CompileScript(conf, declaration.attribute, &compiledAttribute->key)) { 33 | return false; 34 | } 35 | 36 | return CompileScript(conf, declaration.script, &compiledAttribute->value); 37 | } 38 | -------------------------------------------------------------------------------- /exporters/fluentd/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_SOURCE_DIR}/exporters/fluentd/include) 2 | 3 | add_library(foo_library_trace trace/foo_library/foo_library.cc) 4 | 5 | target_link_libraries(foo_library_trace opentelemetry_exporter_geneva_trace 6 | ${CMAKE_THREAD_LIBS_INIT}) 7 | 8 | add_executable(fluentd_example_trace trace/main.cc) 9 | if(MAIN_PROJECT) 10 | target_link_libraries(fluentd_example_trace ${CMAKE_THREAD_LIBS_INIT} 11 | foo_library_trace opentelemetry-cpp::trace) 12 | else() 13 | target_link_libraries(fluentd_example_trace ${CMAKE_THREAD_LIBS_INIT} 14 | foo_library_trace opentelemetry_trace) 15 | endif() 16 | 17 | add_library(foo_library_logs log/foo_library/foo_library.cc) 18 | 19 | target_link_libraries(foo_library_logs opentelemetry_exporter_geneva_logs 20 | ${CMAKE_THREAD_LIBS_INIT}) 21 | 22 | add_executable(fluentd_example_logs log/main.cc) 23 | if(MAIN_PROJECT) 24 | target_link_libraries(fluentd_example_logs ${CMAKE_THREAD_LIBS_INIT} 25 | foo_library_logs opentelemetry-cpp::logs) 26 | else() 27 | target_link_libraries(fluentd_example_logs ${CMAKE_THREAD_LIBS_INIT} 28 | foo_library_logs opentelemetry_logs) 29 | endif() 30 | -------------------------------------------------------------------------------- /exporters/geneva-trace/tools/nuget/OpenTelemetry.Cpp.Geneva.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenTelemetry.Cpp.Geneva 4 | 0.0.0 5 | Microsoft 6 | false 7 | Apache-2.0 8 | https://licenses.nuget.org/Apache-2.0 9 | opentelemetry-icon-color.png 10 | https://opentelemetry.io/ 11 | OpenTelemetry C++ API/SDK with Geneva Exporter 12 | Observability OpenTelemetry Monitoring Telemetry Tracing native C++ Geneva 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /instrumentation/nginx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(opentelemetry-nginx) 4 | 5 | option(WITH_ABSEIL "Use abseil" OFF) 6 | 7 | find_package(opentelemetry-cpp CONFIG REQUIRED) 8 | find_package(nlohmann_json) 9 | find_package(Threads REQUIRED) 10 | find_package(Protobuf REQUIRED) 11 | find_package(CURL REQUIRED) 12 | 13 | if (WITH_ABSEIL) 14 | find_package(absl REQUIRED) 15 | endif() 16 | 17 | include(${CMAKE_CURRENT_SOURCE_DIR}/nginx.cmake) 18 | 19 | add_library(otel_ngx_module SHARED 20 | src/nginx_config.cpp 21 | src/trace_context.cpp 22 | src/otel_ngx_module.cpp 23 | src/otel_ngx_module_modules.c 24 | src/propagate.cpp 25 | src/script.cpp 26 | ) 27 | 28 | target_compile_options(otel_ngx_module 29 | PRIVATE -Wall -Wextra 30 | ) 31 | 32 | install(TARGETS otel_ngx_module DESTINATION ".") 33 | 34 | # Omit the lib prefix to be more in line with nginx module naming 35 | set_target_properties(otel_ngx_module PROPERTIES 36 | PREFIX "" 37 | ) 38 | 39 | add_dependencies(otel_ngx_module project_nginx) 40 | 41 | target_include_directories(otel_ngx_module 42 | PRIVATE 43 | ${NGINX_INCLUDE_DIRS} 44 | ${OPENTELEMETRY_CPP_INCLUDE_DIRS} 45 | ) 46 | target_link_libraries(otel_ngx_module 47 | PRIVATE 48 | ${OPENTELEMETRY_CPP_LIBRARIES} 49 | CURL::libcurl 50 | ) 51 | -------------------------------------------------------------------------------- /exporters/geneva/include/opentelemetry/exporters/geneva/metrics/etw_data_transport.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "opentelemetry/exporters/geneva/metrics/connection_string_parser.h" 7 | #include "opentelemetry/exporters/geneva/metrics/data_transport.h" 8 | #include "opentelemetry/version.h" 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | OPENTELEMETRY_BEGIN_NAMESPACE 15 | namespace exporter { 16 | namespace geneva { 17 | namespace metrics { 18 | static const REGHANDLE INVALID_HANDLE = _UI64_MAX; 19 | static const GUID kMDMProviderGUID = { 20 | 0xedc24920, 0xe004, 0x40f6, 0xa8, 0xe1, 0x0e, 0x6e, 0x48, 0xf3, 0x9d, 0x84}; 21 | 22 | class ETWDataTransport : public DataTransport { 23 | public: 24 | ETWDataTransport(const size_t offset_to_skip_); 25 | bool Connect() noexcept override; 26 | bool Send(MetricsEventType event_type, const char *data, 27 | uint16_t length) noexcept override; 28 | bool Disconnect() noexcept override; 29 | ~ETWDataTransport(); 30 | 31 | private: 32 | REGHANDLE provider_handle_; 33 | bool connected_{false}; 34 | const size_t offset_to_skip_; 35 | }; 36 | } // namespace metrics 37 | } // namespace geneva 38 | } // namespace exporter 39 | OPENTELEMETRY_END_NAMESPACE -------------------------------------------------------------------------------- /instrumentation/nginx/test/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | collector: 3 | image: otel/opentelemetry-collector:latest 4 | command: ["--config=/etc/otel/config.yml"] 5 | volumes: 6 | - ${TEST_ROOT:-.}/conf/collector.yml:/etc/otel/config.yml 7 | - ${TEST_ROOT:-.}/data/trace.json:/trace.json 8 | ports: 9 | - "4318:4318" 10 | - "13133:13133" # health check 11 | nginx: 12 | image: otel-nginx-test/nginx:latest 13 | volumes: 14 | - ${TEST_ROOT:-.}/conf/nginx.conf:/otel-nginx/nginx.conf 15 | - ${TEST_ROOT:-.}/conf/fastcgi_params:/etc/nginx/fastcgi_params 16 | - ${TEST_ROOT:-.}/backend/files:/var/www/html/files 17 | environment: 18 | - OTEL_EXPORTER_OTLP_ENDPOINT=collector:4318/v1/traces 19 | ports: 20 | - "8080:8080" 21 | command: 22 | - /nginx/sbin/nginx 23 | - -c 24 | - /otel-nginx/nginx.conf 25 | depends_on: 26 | - node-backend 27 | - php-backend 28 | - collector 29 | node-backend: 30 | image: otel-nginx-test/express-backend:latest 31 | command: node index.js 32 | volumes: 33 | - ${TEST_ROOT:-.}/backend/simple_express:/app 34 | ports: 35 | - "3500:3500" 36 | php-backend: 37 | image: bitnami/php-fpm:7.4-prod 38 | volumes: 39 | - ${TEST_ROOT:-.}/backend/php/:/var/www/html/php 40 | -------------------------------------------------------------------------------- /exporters/prometheus/WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2022, OpenTelemetry Authors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | workspace(name = "io_opentelemetry_cpp_contrib") 16 | 17 | # Load our direct dependencies. 18 | load("//:repository.bzl", "io_opentelemetry_cpp_contrib_deps") 19 | 20 | io_opentelemetry_cpp_contrib_deps() 21 | 22 | load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps") 23 | 24 | # Load dependencies of opentelemetry-cpp 25 | opentelemetry_cpp_deps() 26 | 27 | load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps") 28 | 29 | opentelemetry_extra_deps() 30 | 31 | # Load prometheus C++ dependencies. 32 | load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories") 33 | 34 | prometheus_cpp_repositories() 35 | -------------------------------------------------------------------------------- /exporters/geneva/include/opentelemetry/exporters/geneva/metrics/data_transport.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "opentelemetry/version.h" 7 | 8 | #include 9 | 10 | OPENTELEMETRY_BEGIN_NAMESPACE 11 | namespace exporter { 12 | namespace geneva { 13 | namespace metrics { 14 | 15 | // These enums are defined in 16 | // file: test/decoder/ifx_metrics_bin.ksy (enum metric_event_type) 17 | enum class MetricsEventType : uint16_t { 18 | Uint64Metric = 50, 19 | DoubleScaledToLongMetric = 51, 20 | BatchMetric = 52, 21 | ExternallyAggregatedUlongMetric = 53, 22 | ExternallyAggregatedDoubleMetric = 54, 23 | DoubleMetric = 55, 24 | ExternallyAggregatedUlongDistributionMetric = 56, 25 | ExternallyAggregatedDoubleDistributionMetric = 57, 26 | ExternallyAggregatedDoubleScaledToLongDistributionMetric = 58, 27 | Undefined = 100 28 | }; 29 | 30 | class DataTransport { 31 | public: 32 | virtual bool Connect() noexcept = 0; 33 | virtual bool Send(MetricsEventType event_type, const char *data, 34 | uint16_t length) noexcept = 0; 35 | virtual bool Disconnect() noexcept = 0; 36 | virtual ~DataTransport() = default; 37 | }; 38 | } // namespace metrics 39 | } // namespace geneva 40 | } // namespace exporter 41 | OPENTELEMETRY_END_NAMESPACE 42 | -------------------------------------------------------------------------------- /instrumentation/nginx/nginx.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | if (NOT NGINX_VERSION) 4 | find_program(NGINX_BIN nginx REQUIRED) 5 | execute_process(COMMAND ${NGINX_BIN} -v 6 | ERROR_VARIABLE NGINX_VERSION_STRING 7 | ) 8 | 9 | string(REGEX MATCH "[0-9]+\\.\[0-9]+\\.[0-9]+" NGINX_VER ${NGINX_VERSION_STRING}) 10 | else() 11 | set(NGINX_VER "1.27.1") 12 | endif() 13 | 14 | set(NGINX_VERSION ${NGINX_VER} CACHE STRING "Nginx version to compile against") 15 | message(STATUS "nginx: using version ${NGINX_VERSION}") 16 | 17 | option(NGINX_WITH_COMPAT "Enable --with-compat for the nginx module" ON) 18 | 19 | if (NGINX_WITH_COMPAT) 20 | message(STATUS "nginx: --with-compat enabled") 21 | set(NGINX_CONFIGURE_ARGS "--with-compat") 22 | else() 23 | message(STATUS "nginx: --with-compat disabled") 24 | endif() 25 | 26 | ExternalProject_Add(project_nginx 27 | URL "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" 28 | PREFIX "nginx" 29 | BUILD_IN_SOURCE 1 30 | CONFIGURE_COMMAND ./configure ${NGINX_CONFIGURE_ARGS} 31 | BUILD_COMMAND "" 32 | INSTALL_COMMAND "" 33 | ) 34 | 35 | set(NGINX_DIR "${CMAKE_BINARY_DIR}/nginx/src/project_nginx") 36 | 37 | set(NGINX_INCLUDE_DIRS 38 | ${NGINX_DIR}/objs 39 | ${NGINX_DIR}/src/core 40 | ${NGINX_DIR}/src/os/unix 41 | ${NGINX_DIR}/src/event 42 | ${NGINX_DIR}/src/http 43 | ${NGINX_DIR}/src/http/modules 44 | ) 45 | -------------------------------------------------------------------------------- /exporters/geneva/include/opentelemetry/exporters/geneva/metrics/unix_domain_socket_data_transport.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include "opentelemetry/exporters/geneva/metrics/connection_string_parser.h" 7 | #include "opentelemetry/exporters/geneva/metrics/data_transport.h" 8 | #include "opentelemetry/exporters/geneva/metrics/socket_tools.h" 9 | #include "opentelemetry/version.h" 10 | 11 | #include 12 | 13 | OPENTELEMETRY_BEGIN_NAMESPACE 14 | namespace exporter { 15 | namespace geneva { 16 | namespace metrics { 17 | class UnixDomainSocketDataTransport : public DataTransport { 18 | public: 19 | UnixDomainSocketDataTransport(const std::string &connection_string); 20 | bool Connect() noexcept override; 21 | bool Send(MetricsEventType event_type, const char *data, 22 | uint16_t length) noexcept override; 23 | bool Disconnect() noexcept override; 24 | ~UnixDomainSocketDataTransport() = default; 25 | 26 | private: 27 | // Socket connection is re-established for every batch of events 28 | const SocketTools::SocketParams socketparams_{AF_UNIX, SOCK_STREAM, 0}; 29 | SocketTools::Socket socket_; 30 | std::unique_ptr addr_; 31 | bool connected_{false}; 32 | }; 33 | } // namespace metrics 34 | } // namespace geneva 35 | } // namespace exporter 36 | OPENTELEMETRY_END_NAMESPACE -------------------------------------------------------------------------------- /instrumentation/httpd/tests/01-create-root-span.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that span is created" 4 | 5 | . tools.sh 6 | 7 | setup_test () { 8 | 9 | cat << EOF > ${HTTPD_CONFIG} 10 | OpenTelemetryExporter file 11 | OpenTelemetryPath ${OUTPUT_SPANS} 12 | EOF 13 | 14 | } 15 | 16 | run_test() { 17 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page" 18 | } 19 | 20 | 21 | check_results() { 22 | echo Checking that exactly one span was created 23 | count '{' 1 # total one span 24 | 25 | echo Checking span fields 26 | check name 'HTTP GET' 27 | check 'span kind' Server 28 | [ "`getSpanField span_id`" != "`getSpanField parent_span_id`" ] || fail "Bad span: span.id same as parent span.id" 29 | 30 | echo Checking span attributes 31 | 32 | [[ "`getSpanAttr 'http.method'`" == "GET" ]] || fail "Bad span attribiute http.method ${SPAN_ATTRS[http.method]}" 33 | [[ "`getSpanAttr 'http.target'`" == "/" ]] || fail "Bad span attribiute http.target ${SPAN_ATTRS[http.target]}" 34 | [[ "`getSpanAttr 'http.status_code'`" == "200" ]] || fail "Bad span attribiute http.status_code ${SPAN_ATTRS[http.status_code]}" 35 | [[ "`getSpanAttr 'http.flavor'`" == "1.1" ]] || fail "Bad span attribiute http.flavor ${SPAN_ATTRS[http.flavor]}" 36 | [[ "`getSpanAttr 'http.scheme'`" == "http" ]] || fail "Bad span attribiute http.scheme ${SPAN_ATTRS[http.scheme]}" 37 | } 38 | 39 | run $@ 40 | -------------------------------------------------------------------------------- /instrumentation/log4cxx/src/appender.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace log4cxx 12 | { 13 | 14 | IMPLEMENT_LOG4CXX_OBJECT(OpenTelemetryAppender) 15 | 16 | void OpenTelemetryAppender::append(const spi::LoggingEventPtr &event, helpers::Pool &) 17 | { 18 | static constexpr auto kLibraryName = "log4cxx"; 19 | 20 | auto provider = opentelemetry::logs::Provider::GetLoggerProvider(); 21 | auto logger = provider->GetLogger(event->getLoggerName(), kLibraryName, libraryVersion()); 22 | auto log_record = logger->CreateLogRecord(); 23 | 24 | if (log_record) 25 | { 26 | using namespace opentelemetry::trace::SemanticConventions; 27 | 28 | log_record->SetSeverity(levelToSeverity(event->getLevel()->toInt())); 29 | log_record->SetBody(event->getMessage()); 30 | log_record->SetTimestamp(event->getChronoTimeStamp()); 31 | log_record->SetAttribute(kCodeFilepath, event->getLocationInformation().getFileName()); 32 | log_record->SetAttribute(kCodeLineno, event->getLocationInformation().getLineNumber()); 33 | log_record->SetAttribute(kThreadName, event->getThreadName()); 34 | logger->EmitLogRecord(std::move(log_record)); 35 | } 36 | } 37 | 38 | } // namespace log4cxx 39 | -------------------------------------------------------------------------------- /instrumentation/httpd/opentelemetry.conf: -------------------------------------------------------------------------------- 1 | 2 | # OpenTelemetryExporter set exporter type: 3 | # file - means put spans into file 4 | # otlp - means use otlp 5 | 6 | OpenTelemetryExporter file 7 | # if you don't specify path for exporter by default standard error will be used 8 | # which is just simply apache error log 9 | OpenTelemetryPath /tmp/output-spans 10 | 11 | # OpenTelemetryExporter otlp 12 | # OpenTelemetryEndpoint host.docker.internal:4317 13 | 14 | # OpenTelemetryBatch for batch configuration. Takes 3 arguments: 15 | # Max Queue Size 16 | # Delay (in milliseconds, 1000 = 1s) 17 | # Max Export Batch Size 18 | 19 | # OpenTelemetryBatch 10 5000 5 20 | 21 | # OpenTelemetryPropagators sets which context propagator should be used (defaults to none) 22 | # currently supported values are (only one can be specified at the moment): 23 | # trace-context - headers: tracestate, traceparent 24 | # b3 - single header (b3) 25 | # b3-multiheader - headers: X-B3-TraceId, X-B3-SpanId 26 | 27 | # OpenTelemetryPropagators b3-multiheader 28 | 29 | # OpenTelemetryIgnoreInbound (defaults to on) indicates that we don't trust incoming context. 30 | # This is safe when httpd is an edge server with traffic from Internet. Set it to false only 31 | # if you run httpd in safe environment. 32 | 33 | # OpenTelemetryIgnoreInbound off 34 | 35 | # OpenTelemetrySetResource service.name apache-web-server 36 | # OpenTelemetrySetAttribute foo bar 37 | 38 | 39 | -------------------------------------------------------------------------------- /exporters/prometheus/.bazelrc: -------------------------------------------------------------------------------- 1 | # bazel configurations for running tests under sanitizers. 2 | # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc 3 | 4 | # --config=asan : Address Sanitizer. 5 | common:asan --copt -DADDRESS_SANITIZER 6 | common:asan --copt -fsanitize=address,bool,float-cast-overflow,integer-divide-by-zero,null,return,returns-nonnull-attribute,shift-exponent,signed-integer-overflow,unreachable,vla-bound 7 | common:asan --copt -fsanitize-address-use-after-scope 8 | common:asan --copt -fno-sanitize-recover=all 9 | common:asan --linkopt -fsanitize=address,bool,float-cast-overflow,integer-divide-by-zero,null,return,returns-nonnull-attribute,shift-exponent,signed-integer-overflow,unreachable,vla-bound 10 | common:asan --linkopt -fsanitize-address-use-after-scope 11 | common:asan --linkopt -fno-sanitize-recover=all 12 | common:asan --cc_output_directory_tag=asan 13 | 14 | # --config=tsan : Thread Sanitizer. 15 | common:tsan --copt -fsanitize=thread 16 | common:tsan --copt -DTHREAD_SANITIZER 17 | common:tsan --linkopt -fsanitize=thread 18 | common:tsan --cc_output_directory_tag=tsan 19 | # This is needed to address false positive problem with abseil.The same setting as gRPC 20 | # https://github.com/google/sanitizers/issues/953 21 | common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0 22 | 23 | # --config=legacy : GCC 4.8 24 | common:legacy --copt=-D__STDC_NO_ATOMICS__ --copt=-Wno-error=shadow --protocopt=--experimental_allow_proto3_optional 25 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/simple_copy.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | """A clone of the default copy.deepcopy that doesn't handle cyclic 6 | structures or complex types except for dicts and lists. This is 7 | because gyp copies so large structure that small copy overhead ends up 8 | taking seconds in a project the size of Chromium.""" 9 | 10 | class Error(Exception): 11 | pass 12 | 13 | __all__ = ["Error", "deepcopy"] 14 | 15 | def deepcopy(x): 16 | """Deep copy operation on gyp objects such as strings, ints, dicts 17 | and lists. More than twice as fast as copy.deepcopy but much less 18 | generic.""" 19 | 20 | try: 21 | return _deepcopy_dispatch[type(x)](x) 22 | except KeyError: 23 | raise Error('Unsupported type %s for deepcopy. Use copy.deepcopy ' + 24 | 'or expand simple_copy support.' % type(x)) 25 | 26 | _deepcopy_dispatch = d = {} 27 | 28 | def _deepcopy_atomic(x): 29 | return x 30 | 31 | for x in (type(None), int, long, float, 32 | bool, str, unicode, type): 33 | d[x] = _deepcopy_atomic 34 | 35 | def _deepcopy_list(x): 36 | return [deepcopy(a) for a in x] 37 | d[list] = _deepcopy_list 38 | 39 | def _deepcopy_dict(x): 40 | y = {} 41 | for key, value in x.iteritems(): 42 | y[deepcopy(key)] = deepcopy(value) 43 | return y 44 | d[dict] = _deepcopy_dict 45 | 46 | del d 47 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | version '1.0' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | implementation 'org.projectlombok:lombok:1.18.16' 13 | implementation 'org.testng:testng:7.1.0' 14 | annotationProcessor 'org.projectlombok:lombok:1.18.16' 15 | testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' 16 | testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' 17 | implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13' 18 | implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36' 19 | implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' 20 | implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.13.2' 21 | implementation group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.1.1' 22 | testImplementation group: 'io.rest-assured', name: 'rest-assured', version: '4.5.1' 23 | testImplementation group: 'org.testng', name: 'testng', version: '6.14.3' 24 | testImplementation group: 'io.rest-assured', name: 'json-schema-validator', version: '4.3.0' 25 | implementation group: 'org.json', name: 'json', version: '20160810' 26 | 27 | } 28 | 29 | task integrationTests(type: Test) { 30 | useTestNG() { 31 | useDefaultListeners = true 32 | suites 'src/test/resources/testngsuites/testng.xml' 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /exporters/fluentd/example/trace/main.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/sdk/trace/simple_processor.h" 5 | #include "opentelemetry/sdk/trace/tracer_provider.h" 6 | #include "opentelemetry/trace/provider.h" 7 | 8 | // Using an exporter that simply dumps span data to stdout. 9 | #include "foo_library/foo_library.h" 10 | #include "opentelemetry/exporters/fluentd/trace/fluentd_exporter.h" 11 | 12 | namespace sdktrace = opentelemetry::sdk::trace; 13 | namespace nostd = opentelemetry::nostd; 14 | 15 | #ifndef HAVE_CONSOLE_LOG 16 | #define HAVE_CONSOLE_LOG 17 | #endif 18 | 19 | namespace { 20 | void initTracer() { 21 | opentelemetry::exporter::fluentd::common::FluentdExporterOptions options; 22 | options.endpoint = "tcp://localhost:24222"; 23 | 24 | auto exporter = std::unique_ptr( 25 | new opentelemetry::exporter::fluentd::trace::FluentdExporter(options)); 26 | auto processor = std::unique_ptr( 27 | new sdktrace::SimpleSpanProcessor(std::move(exporter))); 28 | auto provider = nostd::shared_ptr( 29 | new sdktrace::TracerProvider(std::move(processor))); 30 | 31 | // Set the global trace provider 32 | opentelemetry::trace::Provider::SetTracerProvider(provider); 33 | } 34 | } // namespace 35 | 36 | int main() { 37 | // Removing this line will leave the default noop TracerProvider in place. 38 | initTracer(); 39 | 40 | foo_library(); 41 | } 42 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/core/api/SpanNamer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #pragma once 17 | 18 | #include 19 | 20 | namespace otel { 21 | namespace core { 22 | 23 | enum class SegmentType 24 | { 25 | FIRST, 26 | LAST, 27 | CUSTOM 28 | }; 29 | 30 | enum class SpanNamingRule 31 | { 32 | URLSEGMENT 33 | }; 34 | 35 | class SpanNamer 36 | { 37 | public: 38 | SpanNamer(); 39 | ~SpanNamer() = default; 40 | 41 | void setSegmentRules(const std::string& segmentType, const std::string& segmentParameter); 42 | std::string getSpanName(const std::string& uri); 43 | 44 | private: 45 | void setSegmentType(const std::string& type); 46 | void validateAndSetSegmentParameter(const std::string& segmentParameter); 47 | 48 | private: 49 | SegmentType segmentType; 50 | unsigned segmentCount; 51 | std::string segmentValues; 52 | }; 53 | 54 | } // core 55 | } // otel 56 | 57 | 58 | -------------------------------------------------------------------------------- /exporters/fluentd/cmake/nlohmann-json.cmake: -------------------------------------------------------------------------------- 1 | if("${nlohmann-json}" STREQUAL "") 2 | set(nlohmann-json "v3.9.1") 3 | endif() 4 | include(ExternalProject) 5 | ExternalProject_Add(nlohmann_json_download 6 | PREFIX nlohmann_json 7 | GIT_REPOSITORY https://github.com/nlohmann/json.git 8 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/nlohmann_json" 9 | GIT_TAG 10 | "${nlohmann-json}" 11 | GIT_SHALLOW 1 12 | UPDATE_COMMAND "" 13 | CMAKE_ARGS 14 | -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 15 | -DJSON_BuildTests=OFF 16 | -DJSON_Install=ON 17 | -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 18 | TEST_AFTER_INSTALL 19 | 0 20 | DOWNLOAD_NO_PROGRESS 21 | 1 22 | LOG_CONFIGURE 23 | 1 24 | LOG_BUILD 25 | 1 26 | LOG_INSTALL 27 | 1 28 | ) 29 | 30 | ExternalProject_Get_Property(nlohmann_json_download INSTALL_DIR) 31 | SET(NLOHMANN_JSON_INCLUDE_DIR ${INSTALL_DIR}/nlohmann_json/src/nlohmann_json_download/single_include) 32 | add_library(nlohmann_json_ INTERFACE) 33 | target_include_directories(nlohmann_json_ INTERFACE 34 | "$" 35 | "$") 36 | add_dependencies(nlohmann_json_ nlohmann_json_download) 37 | add_library(nlohmann_json::nlohmann_json ALIAS nlohmann_json_) 38 | 39 | install( 40 | TARGETS nlohmann_json_ 41 | EXPORT "${PROJECT_NAME}-target" 42 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 43 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 44 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 45 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/core/sdkwrapper/ISdkHelperFactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __ISDKHELPERFACTORY_H 18 | #define __ISDKHELPERFACTORY_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include "opentelemetry/trace/tracer.h" 24 | #include "opentelemetry/context/propagation/text_map_propagator.h" 25 | 26 | namespace otel { 27 | namespace core { 28 | 29 | using OtelTracer = opentelemetry::nostd::shared_ptr; 30 | using OtelPropagators = std::vector>; 32 | 33 | namespace sdkwrapper { 34 | 35 | class ISdkHelperFactory { 36 | public: 37 | virtual ~ISdkHelperFactory() = default; 38 | virtual OtelTracer GetTracer() = 0; 39 | virtual OtelPropagators& GetPropagators() = 0; 40 | }; 41 | 42 | } // sdkwrapper 43 | } // core 44 | } // otel 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /instrumentation/httpd/tests/09-check-environment-vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEST_NAME="Check that tracestate and traceparent are available as variables" 4 | 5 | . tools.sh 6 | 7 | EXTRA_LOG_FILE=/tmp/apache-test-$$.log 8 | 9 | setup_test () { 10 | 11 | EXTRA_HTTPD_MODS="headers" 12 | 13 | # here we are setting apache log to record environment variables created by mod_otel 14 | # header set is just an extra debug information so it is also 15 | # visible on standard output when running test during CI/CD cycle 16 | cat << EOF > ${HTTPD_CONFIG} 17 | OpenTelemetryExporter file 18 | OpenTelemetryPath ${OUTPUT_SPANS} 19 | Header set x-env-spanid %{OTEL_SPANID}e 20 | Header set x-env-traceid %{OTEL_TRACEID}e 21 | Header set x-env-traceflags %{OTEL_TRACEFLAGS}e 22 | Header set x-env-tracestate %{OTEL_TRACESTATE}e 23 | LogFormat "span=%{OTEL_SPANID}e trace=%{OTEL_TRACEID}e flags=%{OTEL_TRACEFLAGS}e state=%{OTEL_TRACESTATE}e" otel_format 24 | GlobalLog ${EXTRA_LOG_FILE} otel_format 25 | EOF 26 | 27 | } 28 | 29 | run_test() { 30 | ${CURL_CMD} ${ENDPOINT_URL} || fail "Unable to download main page" 31 | } 32 | 33 | check_results() { 34 | echo Checking that log file contains information 35 | grep --color -E "span=[0-9a-f]{16}" ${EXTRA_LOG_FILE} || fail "SpanID not found in log file" 36 | grep --color -E "trace=[0-9a-f]{32}" ${EXTRA_LOG_FILE} || fail "TraceID not found in log file" 37 | grep --color -E "flags=1" ${EXTRA_LOG_FILE} || fail "TraceFlags not found in log file" 38 | } 39 | 40 | teardown_test() { 41 | rm -rf ${OUTPUT_SPANS} ${EXTRA_LOG_FILE} 42 | } 43 | 44 | run $@ 45 | -------------------------------------------------------------------------------- /exporters/fluentd/include/opentelemetry/exporters/geneva/geneva_exporter_options.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | OPENTELEMETRY_BEGIN_NAMESPACE 10 | 11 | namespace exporters { 12 | 13 | namespace geneva { 14 | 15 | constexpr const char *kUnixDomainScheme = "unix://"; 16 | constexpr const size_t kUnixDomainSchemeLength = 7; // length of "unix://" 17 | struct GenevaExporterOptions { 18 | 19 | /** socker path for unix domain socket. Should start with unix:// 20 | * Example unix:///tmp/.socket_geneva_exporter 21 | */ 22 | std::string socket_endpoint ; 23 | 24 | /* number of retries before failing */ 25 | 26 | size_t retry_count = 2; 27 | 28 | /** 29 | * The maximum buffer/queue size. After the size is reached, spans/logs are 30 | * dropped. 31 | */ 32 | size_t max_queue_size = 2048; // max buffer size dropping logs/spans 33 | 34 | /* The time interval between two consecutive exports. */ 35 | std::chrono::milliseconds schedule_delay_millis = std::chrono::milliseconds(5000); 36 | 37 | /** 38 | * The maximum batch size of every export. It must be smaller or 39 | * equal to max_queue_size. 40 | */ 41 | size_t max_export_batch_size = 512; 42 | 43 | /** 44 | * @brief Include trace_state in the exported spans, default to false. 45 | * 46 | */ 47 | bool include_trace_state_for_span = false; 48 | }; 49 | 50 | } 51 | } 52 | OPENTELEMETRY_END_NAMESPACE 53 | 54 | -------------------------------------------------------------------------------- /exporters/user_events/example/logs/foo_library.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/logs/event_id.h" 5 | #include "opentelemetry/logs/provider.h" 6 | #include "opentelemetry/sdk/version/version.h" 7 | 8 | namespace logs = opentelemetry::logs; 9 | namespace nostd = opentelemetry::nostd; 10 | 11 | const logs::EventId fruit_sell_event_id{0x1, "FruitCompany.SalesDepartment.SellFruit"}; 12 | const logs::EventId fruit_not_found_event_id{0x2, "FruitCompany.SalesDepartment.FruitNotFound"}; 13 | 14 | std::map fruit_inventory = {{"apple", 1}, {"orange", 2}, {"banana", 3}}; 15 | 16 | namespace 17 | { 18 | nostd::shared_ptr get_logger() 19 | { 20 | auto provider = logs::Provider::GetLoggerProvider(); 21 | return provider->GetLogger("fruit_selling"); 22 | } 23 | } // namespace 24 | 25 | void sell_fruit(std::string_view fruit) 26 | { 27 | auto logger = get_logger(); 28 | 29 | if (fruit_inventory.find(std::string{fruit}) == fruit_inventory.end()) 30 | { 31 | logger->Error( 32 | fruit_not_found_event_id, "Fruit {fruit_name} not found in inventory with {error_code}", 33 | opentelemetry::common::MakeAttributes({{"fruit_name", fruit.data()}, {"error_code", 404}})); 34 | 35 | return; 36 | } 37 | 38 | logger->Trace(fruit_sell_event_id, "Selling fruit {fruit_name} with {fruit_price}", 39 | opentelemetry::common::MakeAttributes( 40 | {{"fruit_name", fruit.data()}, 41 | {"fruit_price", static_cast(fruit_inventory[fruit.data()])}})); 42 | } 43 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /exporters/prometheus/opentelemetry-cpp-contrib-config.cmake.in: -------------------------------------------------------------------------------- 1 | # .rst: opentelemetry-cpp-contrib.cmake 2 | # -------- 3 | # 4 | # Find the native opentelemetry-cpp-contrib includes and library. 5 | # 6 | # ============================================================================= 7 | # Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | # use this file except in compliance with the License. You may obtain a copy of 9 | # the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 | # License for the specific language governing permissions and limitations under 17 | # the License. 18 | # ============================================================================= 19 | # (To distribute this file outside of CMake, substitute the full License text 20 | # for the above reference.) 21 | 22 | set(${CMAKE_FIND_PACKAGE_NAME}_VERSION "@PROJECT_VERSION@") 23 | 24 | @PACKAGE_INIT@ 25 | 26 | # ############################################################################## 27 | # ${CMAKE_FIND_PACKAGE_NAME} source dir 28 | 29 | set_and_check(${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS 30 | "@PACKAGE_INCLUDE_INSTALL_DIR@") 31 | set_and_check(${CMAKE_FIND_PACKAGE_NAME}_LIBRARY_DIRS 32 | "@PACKAGE_CMAKE_INSTALL_LIBDIR@") 33 | 34 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-target.cmake") 35 | 36 | # check_required_components(${CMAKE_FIND_PACKAGE_NAME}) 37 | -------------------------------------------------------------------------------- /examples/ffi/cpprust/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate log; 3 | extern crate env_logger; 4 | use cxx::{CxxString, CxxVector}; 5 | 6 | #[cxx::bridge] 7 | mod ffi { 8 | struct Animal { 9 | value: i32, 10 | } 11 | 12 | struct Person { 13 | name: String, 14 | age: i32, 15 | } 16 | 17 | extern "Rust" { 18 | fn log_string_from_cpp_to_rust_log_crate(message: &CxxString); 19 | fn log_int_from_cpp_to_rust_log_crate(level: i32); 20 | fn log_vector_from_cpp_to_rust_log_crate(attributes: &CxxVector); 21 | fn log_struct_from_cpp_to_rust_log_crate(person: &Person); 22 | fn log_class_from_cpp_to_rust_log_crate(animal: &Animal); 23 | fn init_rust_logger() -> (); 24 | } 25 | 26 | unsafe extern "C++" { 27 | include!("cpprust/src/animal.hpp"); 28 | type Animal; 29 | fn get_age(&self) -> i32; 30 | } 31 | } 32 | 33 | pub fn log_string_from_cpp_to_rust_log_crate(message: &CxxString) { 34 | info!("{}", message); 35 | } 36 | 37 | pub fn log_int_from_cpp_to_rust_log_crate(level: i32) { 38 | info!("{}", level); 39 | } 40 | 41 | pub fn log_vector_from_cpp_to_rust_log_crate(attributes: &CxxVector) { 42 | info!("{:?}", attributes); 43 | } 44 | 45 | pub fn log_struct_from_cpp_to_rust_log_crate(person: &ffi::Person) { 46 | info!("Received persons: {} who is {} years old", person.name, person.age); 47 | } 48 | 49 | pub fn log_class_from_cpp_to_rust_log_crate(animal: &ffi::Animal) { 50 | let value = animal.get_age(); 51 | info!("{}", value); 52 | } 53 | 54 | pub fn init_rust_logger() -> () { 55 | env_logger::init(); 56 | } -------------------------------------------------------------------------------- /exporters/fluentd/example/log/main.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/exporters/fluentd/log/fluentd_exporter.h" 5 | #include "opentelemetry/logs/provider.h" 6 | #include "opentelemetry/sdk/logs/logger_provider.h" 7 | #include "opentelemetry/sdk/logs/simple_log_record_processor.h" 8 | 9 | // Using an exporter that simply dumps span data to stdout. 10 | #include "foo_library/foo_library.h" 11 | 12 | namespace sdk_logs = opentelemetry::sdk::logs; 13 | namespace nostd = opentelemetry::nostd; 14 | 15 | #ifndef HAVE_CONSOLE_LOG 16 | #define HAVE_CONSOLE_LOG 17 | #endif 18 | 19 | namespace { 20 | void initLogger() { 21 | opentelemetry::exporter::fluentd::common::FluentdExporterOptions options; 22 | options.endpoint = "tcp://localhost:24222"; 23 | auto exporter = std::unique_ptr( 24 | new opentelemetry::exporter::fluentd::logs::FluentdExporter(options)); 25 | auto processor = std::unique_ptr( 26 | new sdk_logs::SimpleLogRecordProcessor(std::move(exporter))); 27 | 28 | auto provider = std::shared_ptr( 29 | new opentelemetry::sdk::logs::LoggerProvider(std::move(processor))); 30 | 31 | auto pr = 32 | static_cast(provider.get()); 33 | 34 | // Set the global logger provider 35 | opentelemetry::logs::Provider::SetLoggerProvider(provider); 36 | } 37 | } // namespace 38 | 39 | int main() { 40 | // Removing this line will leave the default noop TracerProvider in place. 41 | initLogger(); 42 | 43 | foo_library(); 44 | } 45 | -------------------------------------------------------------------------------- /instrumentation/httpd/.clang-format: -------------------------------------------------------------------------------- 1 | # See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html 2 | BasedOnStyle: Chromium 3 | 4 | # Allow double brackets such as std::vector>. 5 | Standard: Cpp11 6 | 7 | # Indent 2 spaces at a time. 8 | IndentWidth: 2 9 | 10 | # Keep lines under 100 columns long. 11 | ColumnLimit: 100 12 | 13 | # Always break before braces 14 | BreakBeforeBraces: Custom 15 | BraceWrapping: 16 | # TODO(lujc) wait for clang-format-9 support in Chromium tools 17 | # AfterCaseLabel: true 18 | AfterClass: true 19 | AfterControlStatement: true 20 | AfterEnum: true 21 | AfterFunction: true 22 | AfterNamespace: true 23 | AfterStruct: true 24 | AfterUnion: true 25 | BeforeCatch: true 26 | BeforeElse: true 27 | IndentBraces: false 28 | SplitEmptyFunction: false 29 | SplitEmptyRecord: false 30 | SplitEmptyNamespace: false 31 | 32 | # Keeps extern "C" blocks unindented. 33 | AfterExternBlock: false 34 | 35 | # Indent case labels. 36 | IndentCaseLabels: true 37 | 38 | # Right-align pointers and references 39 | PointerAlignment: Right 40 | 41 | # ANGLE likes to align things as much as possible. 42 | AlignOperands: true 43 | AlignConsecutiveAssignments: true 44 | 45 | # Use 2 space negative offset for access modifiers 46 | AccessModifierOffset: -2 47 | 48 | # TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. 49 | AllowShortCaseLabelsOnASingleLine: false 50 | 51 | # Useful for spacing out functions in classes 52 | KeepEmptyLinesAtTheStartOfBlocks: true 53 | 54 | # Indent nested PP directives. 55 | IndentPPDirectives: AfterHash 56 | 57 | # Include blocks style 58 | IncludeBlocks: Preserve -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/core/sdkwrapper/ISdkWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __ISDKWRAPPER_H 18 | #define __ISDKWRAPPER_H 19 | 20 | #include 21 | #include 22 | #include "sdkwrapper/SdkEnums.h" 23 | #include "sdkwrapper/IScopedSpan.h" 24 | #include "api/TenantConfig.h" 25 | 26 | namespace otel { 27 | namespace core { 28 | namespace sdkwrapper { 29 | 30 | class ISdkWrapper { 31 | public: 32 | virtual ~ISdkWrapper() = default; 33 | 34 | virtual void Init(std::shared_ptr config) = 0; 35 | 36 | virtual std::shared_ptr CreateSpan( 37 | const std::string& name, 38 | const SpanKind& kind, 39 | const OtelKeyValueMap& attributes, 40 | const std::unordered_map& carrier = {}) = 0; 41 | 42 | virtual std::string ReturnCurrentSpanId() = 0; 43 | 44 | virtual void PopulatePropagationHeaders( 45 | std::unordered_map& carrier) = 0; 46 | }; 47 | 48 | } //sdkwrapper 49 | } //core 50 | } //otel 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /exporters/prometheus/README.md: -------------------------------------------------------------------------------- 1 | # Prometheus Push Exporter for OpenTelemetry C++ 2 | 3 | ## Installation 4 | 5 | ### CMake Install Instructions 6 | 7 | + Install opentelemetry-cpp with stable metric and prometheus exporter 8 | 9 | ```bash 10 | mkdir build_jobs 11 | cd build_jobs 12 | cmake -DCMAKE_PREFIX_PATH= .. 13 | 14 | cmake --build . -j 15 | ``` 16 | 17 | ### Bazel Install Instructions 18 | 19 | `bazel build --copt=-DENABLE_TEST --@io_opentelemetry_cpp//api:with_abseil //...` 20 | 21 | ## Usage 22 | 23 | Install the exporter on your application and pass the options. 24 | 25 | ```cpp 26 | #include 27 | 28 | opentelemetry::exporter::metrics::PrometheusPushExporterOptions options; 29 | options.host = "localhost"; 30 | options.port = "80"; 31 | options.jobname = "jobname"; 32 | 33 | auto exporter = std::unique_ptr( 34 | new opentelemetry::exporter::metrics::PrometheusPushExporter(options)); 35 | 36 | opentelemetry::sdk::metrics::PeriodicExportingMetricReaderOptions reader_options; 37 | auto reader = std::unique_ptr( 38 | new opentelemetry::sdk::metrics::PeriodicExportingMetricReader(std::move(exporter), options)); 39 | 40 | auto provider = nostd::shared_ptr( 41 | new opentelemetry::sdk::metrics::MeterProvider()); 42 | static_cast(provider.get())->AddMetricReader(std::move(reader)); 43 | 44 | // Set the global tracer provider 45 | opentelemetry::metrics::Provider::SetMeterProvider(provider); 46 | ``` 47 | -------------------------------------------------------------------------------- /exporters/fluentd/example/log/foo_library/foo_library.cc: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #include "opentelemetry/logs/provider.h" 5 | 6 | namespace logs = opentelemetry::logs; 7 | namespace nostd = opentelemetry::nostd; 8 | 9 | namespace { 10 | nostd::shared_ptr get_logger() { 11 | auto provider = logs::Provider::GetLoggerProvider(); 12 | return provider->GetLogger("foo_library", "", "foo_library"); 13 | } 14 | 15 | void f1() { 16 | auto log_record = get_logger()->CreateLogRecord(); 17 | log_record->SetSeverity(opentelemetry::logs::Severity::kDebug); 18 | log_record->SetAttribute("k1", "v1"); 19 | log_record->SetAttribute("k2", "v2"); 20 | log_record->SetTimestamp(std::chrono::system_clock::now()); 21 | log_record->SetEventId(2, "logName2"); 22 | 23 | get_logger()->EmitLogRecord(std::move(log_record)); 24 | } 25 | 26 | void f2() { 27 | auto log_record = get_logger()->CreateLogRecord(); 28 | log_record->SetSeverity(opentelemetry::logs::Severity::kDebug); 29 | log_record->SetBody("log body - 3"); 30 | log_record->SetTimestamp(std::chrono::system_clock::now()); 31 | log_record->SetEventId(3, "logName3"); 32 | 33 | get_logger()->EmitLogRecord(std::move(log_record)); 34 | 35 | f1(); 36 | f1(); 37 | } 38 | } // namespace 39 | 40 | void foo_library() { 41 | auto log_record = get_logger()->CreateLogRecord(); 42 | log_record->SetSeverity(opentelemetry::logs::Severity::kDebug); 43 | log_record->SetBody("log body - 1"); 44 | log_record->SetTimestamp(std::chrono::system_clock::now()); 45 | log_record->SetEventId(1, "logName1"); 46 | 47 | get_logger()->EmitLogRecord(std::move(log_record)); 48 | } 49 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/apache/ApacheTracing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef APACHETRACING_H 18 | #define APACHETRACING_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /** 26 | * Class that is used to log agent logs into Apache error logs, 27 | * based on the flag "m_traceAsErrorFromUser" set by user. 28 | */ 29 | class ApacheTracing 30 | { 31 | public: 32 | 33 | static bool m_traceAsErrorFromUser; // trace config from user 34 | 35 | enum ApacheTraceStates 36 | { 37 | UNINITIALIZED, 38 | NOTRACE, 39 | TRACE_AS_ERROR 40 | }; 41 | 42 | static void writeTrace(server_rec* s, const char* funcName, const char* note, ...); 43 | static void writeError(server_rec* s, const char* funcName, const char* note, ...); 44 | static void logStartupTrace(server_rec *s); 45 | 46 | private: 47 | static ApacheTraceStates m_state; 48 | static std::vector m_startupTrace; // holds log message until traceLevel is set 49 | }; 50 | #endif 51 | -------------------------------------------------------------------------------- /instrumentation/glog/src/sink.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace google 15 | { 16 | 17 | void OpenTelemetrySink::send(google::LogSeverity severity, 18 | const char *full_filename, 19 | const char * /* base_filename */, 20 | int line, 21 | const google::LogMessageTime &logmsgtime, 22 | const char *message, 23 | size_t message_len) 24 | { 25 | 26 | static constexpr auto kLoggerName = "Google logger"; 27 | static constexpr auto kLibraryName = "glog"; 28 | 29 | auto provider = opentelemetry::logs::Provider::GetLoggerProvider(); 30 | auto logger = provider->GetLogger(kLoggerName, kLibraryName); 31 | auto log_record = logger->CreateLogRecord(); 32 | 33 | if (log_record) 34 | { 35 | using namespace opentelemetry::trace::SemanticConventions; 36 | using namespace std::chrono; 37 | 38 | log_record->SetSeverity(levelToSeverity(severity)); 39 | log_record->SetBody(opentelemetry::nostd::string_view(message, message_len)); 40 | log_record->SetTimestamp(logmsgtime.when()); 41 | log_record->SetAttribute(kCodeFilepath, full_filename); 42 | log_record->SetAttribute(kCodeLineno, line); 43 | logger->EmitLogRecord(std::move(log_record)); 44 | } 45 | } 46 | 47 | } // namespace google 48 | -------------------------------------------------------------------------------- /instrumentation/httpd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(opentelemetry-httpd) 4 | 5 | find_package(opentelemetry-cpp REQUIRED) 6 | find_package(Threads REQUIRED) 7 | find_package(Protobuf REQUIRED) 8 | find_package(gRPC REQUIRED) 9 | find_package(CURL REQUIRED) 10 | find_package(Thrift REQUIRED) 11 | 12 | find_path(APR_INCLUDE_DIR 13 | NAMES apr.h 14 | PATHS /opt/homebrew/opt/apr/include/apr-1 15 | /usr/local/include/apr-1 16 | /usr/local/include/apr-1.0 17 | /usr/include/apr-1 18 | /usr/include/apr-1.0 19 | /usr/local/apr/include/apr-1 20 | ) 21 | 22 | IF(NOT EXISTS "${APR_INCLUDE_DIR}/apr.h") 23 | MESSAGE(FATAL_ERROR "APR include directory ${APR_INCLUDE_DIR} is not correct.") 24 | ENDIF() 25 | 26 | find_path(APACHE_INCLUDE_DIR 27 | NAMES httpd.h 28 | PATHS /usr/include/apache2 29 | /usr/local/include/apache2 30 | ) 31 | 32 | IF(NOT EXISTS "${APACHE_INCLUDE_DIR}/httpd.h") 33 | MESSAGE(FATAL_ERROR "APACHE_INCLUDE_DIR include directory ${APACHE_INCLUDE_DIR} is not correct.") 34 | ENDIF() 35 | 36 | add_library(otel_httpd_module SHARED 37 | src/otel/mod_otel.cpp 38 | src/otel/opentelemetry.cpp 39 | ) 40 | 41 | target_compile_options(otel_httpd_module 42 | PRIVATE -Wall -Wextra 43 | ) 44 | 45 | install(TARGETS otel_httpd_module DESTINATION ".") 46 | 47 | set_target_properties(otel_httpd_module PROPERTIES 48 | PREFIX "" 49 | ) 50 | 51 | target_include_directories(otel_httpd_module 52 | PRIVATE 53 | ${OPENTELEMETRY_CPP_INCLUDE_DIRS} 54 | ${APACHE_INCLUDE_DIR} 55 | ${APR_INCLUDE_DIR} 56 | ) 57 | 58 | target_link_libraries(otel_httpd_module 59 | PRIVATE 60 | ${OPENTELEMETRY_CPP_LIBRARIES} 61 | gRPC::grpc++ 62 | # Thrift::thrift 63 | ) 64 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html 5 | BasedOnStyle: Chromium 6 | 7 | # Allow double brackets such as std::vector>. 8 | Standard: Cpp11 9 | 10 | # Indent 2 spaces at a time. 11 | IndentWidth: 2 12 | 13 | # Keep lines under 100 columns long. 14 | ColumnLimit: 100 15 | 16 | # Always break before braces 17 | BreakBeforeBraces: Custom 18 | BraceWrapping: 19 | # TODO(lujc) wait for clang-format-9 support in Chromium tools 20 | # AfterCaseLabel: true 21 | AfterClass: true 22 | AfterControlStatement: true 23 | AfterEnum: true 24 | AfterFunction: true 25 | AfterNamespace: true 26 | AfterStruct: true 27 | AfterUnion: true 28 | BeforeCatch: true 29 | BeforeElse: true 30 | IndentBraces: false 31 | SplitEmptyFunction: false 32 | SplitEmptyRecord: false 33 | SplitEmptyNamespace: false 34 | 35 | # Keeps extern "C" blocks unindented. 36 | AfterExternBlock: false 37 | 38 | # Indent case labels. 39 | IndentCaseLabels: true 40 | 41 | # Right-align pointers and references 42 | PointerAlignment: Right 43 | 44 | # ANGLE likes to align things as much as possible. 45 | AlignOperands: true 46 | AlignConsecutiveAssignments: true 47 | 48 | # Use 2 space negative offset for access modifiers 49 | AccessModifierOffset: -2 50 | 51 | # TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. 52 | AllowShortCaseLabelsOnASingleLine: false 53 | 54 | # Useful for spacing out functions in classes 55 | KeepEmptyLinesAtTheStartOfBlocks: true 56 | 57 | # Indent nested PP directives. 58 | IndentPPDirectives: AfterHash 59 | 60 | # Include blocks style 61 | IncludeBlocks: Preserve 62 | -------------------------------------------------------------------------------- /.github/workflows/ossf-scorecard.yml: -------------------------------------------------------------------------------- 1 | name: OSSF Scorecard 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | schedule: 8 | - cron: "37 0 * * 4" # once a week 9 | workflow_dispatch: 10 | 11 | permissions: read-all 12 | 13 | jobs: 14 | analysis: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | # Needed for Code scanning upload 18 | security-events: write 19 | # Needed for GitHub OIDC token if publish_results is true 20 | id-token: write 21 | steps: 22 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4.2.2 23 | with: 24 | persist-credentials: false 25 | 26 | - uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 27 | with: 28 | results_file: results.sarif 29 | results_format: sarif 30 | publish_results: true 31 | 32 | # Upload the results as artifacts (optional). Commenting out will disable 33 | # uploads of run results in SARIF format to the repository Actions tab. 34 | # https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts 35 | - name: "Upload artifact" 36 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v3.2.1 37 | with: 38 | name: SARIF file 39 | path: results.sarif 40 | retention-days: 5 41 | 42 | # Upload the results to GitHub's code scanning dashboard (optional). 43 | # Commenting out will disable upload of results to your repo's Code Scanning dashboard 44 | - name: "Upload to code-scanning" 45 | uses: github/codeql-action/upload-sarif@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7 46 | with: 47 | sarif_file: results.sarif -------------------------------------------------------------------------------- /exporters/prometheus/.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html 5 | BasedOnStyle: Chromium 6 | 7 | # Allow double brackets such as std::vector>. 8 | Standard: Cpp11 9 | 10 | # Indent 2 spaces at a time. 11 | IndentWidth: 2 12 | 13 | # Keep lines under 100 columns long. 14 | ColumnLimit: 100 15 | 16 | # Always break before braces 17 | BreakBeforeBraces: Custom 18 | BraceWrapping: 19 | # TODO(lujc) wait for clang-format-9 support in Chromium tools 20 | # AfterCaseLabel: true 21 | AfterClass: true 22 | AfterControlStatement: true 23 | AfterEnum: true 24 | AfterFunction: true 25 | AfterNamespace: true 26 | AfterStruct: true 27 | AfterUnion: true 28 | BeforeCatch: true 29 | BeforeElse: true 30 | IndentBraces: false 31 | SplitEmptyFunction: false 32 | SplitEmptyRecord: false 33 | SplitEmptyNamespace: false 34 | 35 | # Keeps extern "C" blocks unindented. 36 | AfterExternBlock: false 37 | 38 | # Indent case labels. 39 | IndentCaseLabels: true 40 | 41 | # Right-align pointers and references 42 | PointerAlignment: Right 43 | 44 | # ANGLE likes to align things as much as possible. 45 | AlignOperands: true 46 | AlignConsecutiveAssignments: true 47 | 48 | # Use 2 space negative offset for access modifiers 49 | AccessModifierOffset: -2 50 | 51 | # TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. 52 | AllowShortCaseLabelsOnASingleLine: false 53 | 54 | # Useful for spacing out functions in classes 55 | KeepEmptyLinesAtTheStartOfBlocks: true 56 | 57 | # Indent nested PP directives. 58 | IndentPPDirectives: AfterHash 59 | 60 | # Include blocks style 61 | IncludeBlocks: Preserve 62 | -------------------------------------------------------------------------------- /exporters/user_events/.clang-format: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html 5 | BasedOnStyle: Chromium 6 | 7 | # Allow double brackets such as std::vector>. 8 | Standard: Cpp11 9 | 10 | # Indent 2 spaces at a time. 11 | IndentWidth: 2 12 | 13 | # Keep lines under 100 columns long. 14 | ColumnLimit: 100 15 | 16 | # Always break before braces 17 | BreakBeforeBraces: Custom 18 | BraceWrapping: 19 | # TODO(lujc) wait for clang-format-9 support in Chromium tools 20 | # AfterCaseLabel: true 21 | AfterClass: true 22 | AfterControlStatement: true 23 | AfterEnum: true 24 | AfterFunction: true 25 | AfterNamespace: true 26 | AfterStruct: true 27 | AfterUnion: true 28 | BeforeCatch: true 29 | BeforeElse: true 30 | IndentBraces: false 31 | SplitEmptyFunction: false 32 | SplitEmptyRecord: false 33 | SplitEmptyNamespace: false 34 | 35 | # Keeps extern "C" blocks unindented. 36 | AfterExternBlock: false 37 | 38 | # Indent case labels. 39 | IndentCaseLabels: true 40 | 41 | # Right-align pointers and references 42 | PointerAlignment: Right 43 | 44 | # ANGLE likes to align things as much as possible. 45 | AlignOperands: true 46 | AlignConsecutiveAssignments: true 47 | 48 | # Use 2 space negative offset for access modifiers 49 | AccessModifierOffset: -2 50 | 51 | # TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. 52 | AllowShortCaseLabelsOnASingleLine: false 53 | 54 | # Useful for spacing out functions in classes 55 | KeepEmptyLinesAtTheStartOfBlocks: true 56 | 57 | # Indent nested PP directives. 58 | IndentPPDirectives: AfterHash 59 | 60 | # Include blocks style 61 | IncludeBlocks: Preserve 62 | -------------------------------------------------------------------------------- /instrumentation/nginx/test/backend/simple_express/index.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const port = 3500; 4 | 5 | const traceparentRegex = /00-[0-9a-f]{32}-[0-9a-f]{16}-0[0-1]/; 6 | 7 | app.get('/', (req, res) => { 8 | let traceparent = req.header("traceparent"); 9 | if (!traceparentRegex.test(traceparent)) { 10 | throw "Missing traceparent header"; 11 | } 12 | 13 | res.json({traceparent: traceparent}); 14 | }); 15 | 16 | app.get("/b3", (req, res) => { 17 | let header = req.header("b3"); 18 | if (!/[0-9a-f]{32}-[0-9a-f]{16}-[0-1]{1}/.test(header)) { 19 | throw "Missing b3 header"; 20 | } 21 | 22 | res.json({"b3": header}); 23 | }); 24 | 25 | app.get("/b3multi", (req, res) => { 26 | let traceId = req.header("x-b3-traceid"); 27 | let spanId = req.header("x-b3-spanid"); 28 | let sampled = req.header("x-b3-sampled"); 29 | 30 | if (!/^([0-9a-f]{32}|[0-9a-f]{16})$/.test(traceId)) { 31 | throw "Missing x-b3-traceid header"; 32 | } 33 | 34 | if (!/^[0-9a-f]{16}$/.test(spanId)) { 35 | throw "Missing x-b3-spanid header"; 36 | } 37 | 38 | if (!["0", "1"].includes(sampled)) { 39 | throw "Missing x-b3-sampled header"; 40 | } 41 | 42 | res.json({ 43 | "x-b3-traceid": traceId, 44 | "x-b3-spanid": spanId, 45 | "x-b3-sampled": sampled 46 | }); 47 | }); 48 | 49 | app.get("/off", (req, res) => { 50 | if (req.header("traceparent") !== undefined) { 51 | throw "Found traceparent header, but expected none"; 52 | } 53 | 54 | res.json({}); 55 | }); 56 | 57 | const server = app.listen(port, () => { 58 | console.log(`simple_express ready at http://localhost:${port}`) 59 | }); 60 | 61 | process.on("SIGTERM", () => server.close()); 62 | process.on("SIGINT", () => server.close()); 63 | -------------------------------------------------------------------------------- /exporters/fluentd/example/fluentd-docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # AUTOMATICALLY GENERATED 2 | # DO NOT EDIT THIS FILE DIRECTLY, USE /Dockerfile.template.erb 3 | 4 | FROM alpine:3.13 5 | LABEL maintainer "Fluentd developers " 6 | LABEL Description="Fluentd docker image" Vendor="Fluent Organization" Version="1.12.3" 7 | 8 | # Do not split this into multiple RUN! 9 | # Docker creates a layer for every RUN-Statement 10 | # therefore an 'apk delete' has no effect 11 | RUN apk update \ 12 | && apk add --no-cache \ 13 | ca-certificates \ 14 | ruby ruby-irb ruby-etc ruby-webrick \ 15 | tini \ 16 | && apk add --no-cache --virtual .build-deps \ 17 | build-base linux-headers \ 18 | ruby-dev gnupg \ 19 | && echo 'gem: --no-document' >> /etc/gemrc \ 20 | && gem install oj -v 3.10.18 \ 21 | && gem install json -v 2.4.1 \ 22 | && gem install async-http -v 0.54.0 \ 23 | && gem install ext_monitor -v 0.1.2 \ 24 | && gem install fluentd -v 1.12.3 \ 25 | && gem install bigdecimal -v 1.4.4 \ 26 | && apk del .build-deps \ 27 | && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem /usr/lib/ruby/gems/2.*/gems/fluentd-*/test 28 | 29 | RUN addgroup -S fluent && adduser -S -g fluent fluent \ 30 | # for log storage (maybe shared with host) 31 | && mkdir -p /fluentd/log \ 32 | # configuration/plugins path (default: copied from .) 33 | && mkdir -p /fluentd/etc /fluentd/plugins \ 34 | && chown -R fluent /fluentd && chgrp -R fluent /fluentd 35 | 36 | COPY fluent.conf /fluentd/etc/ 37 | COPY entrypoint.sh /bin/ 38 | 39 | 40 | ENV FLUENTD_CONF="fluent.conf" 41 | 42 | ENV LD_PRELOAD="" 43 | EXPOSE 5140 8888 24222 24224 24230 44 | 45 | USER fluent 46 | ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"] 47 | CMD ["fluentd"] 48 | -------------------------------------------------------------------------------- /instrumentation/spdlog/src/sink.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The OpenTelemetry Authors 3 | * SPDX-License-Identifier: Apache-2.0 4 | */ 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace spdlog 14 | { 15 | namespace sinks 16 | { 17 | 18 | template 19 | void OpenTelemetrySink::sink_it_(const spdlog::details::log_msg &msg) 20 | { 21 | static constexpr auto kLibraryName = "spdlog"; 22 | 23 | auto provider = opentelemetry::logs::Provider::GetLoggerProvider(); 24 | auto logger = provider->GetLogger(msg.logger_name.data(), kLibraryName, libraryVersion()); 25 | auto log_record = logger->CreateLogRecord(); 26 | 27 | if (log_record) 28 | { 29 | using namespace opentelemetry::semconv::code; 30 | using namespace opentelemetry::semconv::thread; 31 | 32 | log_record->SetSeverity(levelToSeverity(msg.level)); 33 | log_record->SetBody(opentelemetry::nostd::string_view(msg.payload.data(), msg.payload.size())); 34 | log_record->SetTimestamp(msg.time); 35 | if (!msg.source.empty()) 36 | { 37 | log_record->SetAttribute(kCodeFilePath, msg.source.filename); 38 | log_record->SetAttribute(kCodeLineNumber, msg.source.line); 39 | } 40 | log_record->SetAttribute(kThreadId, msg.thread_id); 41 | logger->EmitLogRecord(std::move(log_record)); 42 | } 43 | } 44 | 45 | // Explicit instantiation to avoid linker errors 46 | template class OpenTelemetrySink; 47 | template class OpenTelemetrySink; 48 | 49 | } // namespace sinks 50 | } // namespace spdlog 51 | -------------------------------------------------------------------------------- /exporters/geneva/include/opentelemetry/exporters/geneva/metrics/macros.h: -------------------------------------------------------------------------------- 1 | // Copyright The OpenTelemetry Authors 2 | // SPDX-License-Identifier: Apache-2.0 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | #ifndef TOKENPASTE 9 | #define TOKENPASTE(x, y) x##y 10 | #endif 11 | 12 | #ifndef TOKENPASTE2 13 | #define TOKENPASTE2(x, y) TOKENPASTE(x, y) 14 | #endif 15 | 16 | #ifndef LOCKGUARD 17 | #define LOCKGUARD(macro_mutex) \ 18 | std::lock_guard TOKENPASTE2(__guard_, \ 19 | __LINE__)(macro_mutex) 20 | #endif 21 | 22 | #if defined(HAVE_CONSOLE_LOG) && !defined(LOG_DEBUG) 23 | // Log to console if there's no standard log facility defined 24 | #include 25 | #ifndef LOG_DEBUG 26 | #define LOG_DEBUG(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 27 | #define LOG_TRACE(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 28 | #define LOG_INFO(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 29 | #define LOG_WARN(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 30 | #define LOG_ERROR(fmt_, ...) printf(" " fmt_ "\n", ##__VA_ARGS__) 31 | #endif 32 | #endif 33 | 34 | #ifndef LOG_DEBUG 35 | // Don't log anything if there's no standard log facility defined 36 | #define LOG_DEBUG(fmt_, ...) 37 | #define LOG_TRACE(fmt_, ...) 38 | #define LOG_INFO(fmt_, ...) 39 | #define LOG_WARN(fmt_, ...) 40 | #define LOG_ERROR(fmt_, ...) 41 | #endif 42 | 43 | // Annex K macros 44 | #if !defined(_MSC_VER) 45 | #ifndef strncpy_s 46 | #define strncpy_s(dest, destsz, src, count) \ 47 | strncpy(dest, src, (destsz <= count) ? destsz : count) 48 | #endif 49 | #endif 50 | 51 | // SAL macro 52 | #ifndef _Out_cap_ 53 | #define _Out_cap_(size) 54 | #endif 55 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/flock_tool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Copyright (c) 2011 Google Inc. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | """These functions are executed via gyp-flock-tool when using the Makefile 7 | generator. Used on systems that don't have a built-in flock.""" 8 | 9 | import fcntl 10 | import os 11 | import struct 12 | import subprocess 13 | import sys 14 | 15 | 16 | def main(args): 17 | executor = FlockTool() 18 | executor.Dispatch(args) 19 | 20 | 21 | class FlockTool(object): 22 | """This class emulates the 'flock' command.""" 23 | def Dispatch(self, args): 24 | """Dispatches a string command to a method.""" 25 | if len(args) < 1: 26 | raise Exception("Not enough arguments") 27 | 28 | method = "Exec%s" % self._CommandifyName(args[0]) 29 | getattr(self, method)(*args[1:]) 30 | 31 | def _CommandifyName(self, name_string): 32 | """Transforms a tool name like copy-info-plist to CopyInfoPlist""" 33 | return name_string.title().replace('-', '') 34 | 35 | def ExecFlock(self, lockfile, *cmd_list): 36 | """Emulates the most basic behavior of Linux's flock(1).""" 37 | # Rely on exception handling to report errors. 38 | # Note that the stock python on SunOS has a bug 39 | # where fcntl.flock(fd, LOCK_EX) always fails 40 | # with EBADF, that's why we use this F_SETLK 41 | # hack instead. 42 | fd = os.open(lockfile, os.O_WRONLY|os.O_NOCTTY|os.O_CREAT, 0666) 43 | op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0) 44 | fcntl.fcntl(fd, fcntl.F_SETLK, op) 45 | return subprocess.call(cmd_list) 46 | 47 | 48 | if __name__ == '__main__': 49 | sys.exit(main(sys.argv[1:])) 50 | -------------------------------------------------------------------------------- /instrumentation/nginx/src/script.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern "C" { 4 | #include 5 | #include 6 | #include 7 | } 8 | 9 | #include "nginx_utils.h" 10 | 11 | struct NgxCompiledScript { 12 | ngx_str_t pattern = ngx_null_string; 13 | ngx_array_t* lengths = nullptr; 14 | ngx_array_t* values = nullptr; 15 | 16 | bool Run(ngx_http_request_t* req, ngx_str_t* result) { 17 | if (!lengths) { 18 | *result = pattern; 19 | return true; 20 | } 21 | 22 | if (!ngx_http_script_run(req, result, lengths->elts, 0, values->elts)) { 23 | *result = ngx_null_string; 24 | return false; 25 | } 26 | 27 | return true; 28 | } 29 | 30 | bool IsEmpty() { 31 | return pattern.len == 0; 32 | } 33 | }; 34 | 35 | enum ScriptAttributeType { 36 | ScriptAttributeInt, 37 | ScriptAttributeString, 38 | }; 39 | 40 | struct ScriptAttributeDeclaration { 41 | ScriptAttributeDeclaration( 42 | opentelemetry::nostd::string_view attribute, opentelemetry::nostd::string_view script, ScriptAttributeType type = ScriptAttributeString) 43 | : attribute(ToNgxString(attribute)), script(ToNgxString(script)), type(type) {} 44 | 45 | ScriptAttributeDeclaration(ngx_str_t attribute, ngx_str_t script) 46 | : attribute(attribute), script(script), type(ScriptAttributeString) {} 47 | 48 | ngx_str_t attribute; 49 | ngx_str_t script; 50 | ScriptAttributeType type; 51 | }; 52 | 53 | struct CompiledScriptAttribute { 54 | NgxCompiledScript key; 55 | NgxCompiledScript value; 56 | ScriptAttributeType type; 57 | }; 58 | 59 | bool CompileScript(ngx_conf_t* conf, ngx_str_t pattern, NgxCompiledScript* script); 60 | bool CompileScriptAttribute( 61 | ngx_conf_t* conf, ScriptAttributeDeclaration declaration, 62 | CompiledScriptAttribute* compiledAttribute); 63 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/include/core/sdkwrapper/SdkWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __SDKWRAPPER_H 18 | #define __SDKWRAPPER_H 19 | 20 | #include "sdkwrapper/ISdkWrapper.h" 21 | #include "sdkwrapper/ISdkHelperFactory.h" 22 | #include "AgentLogger.h" 23 | #include 24 | 25 | namespace otel { 26 | namespace core { 27 | namespace sdkwrapper { 28 | 29 | class SdkWrapper : public ISdkWrapper{ 30 | public: 31 | SdkWrapper(); 32 | 33 | void Init(std::shared_ptr config) override; 34 | 35 | std::shared_ptr CreateSpan( 36 | const std::string& name, 37 | const SpanKind& kind, 38 | const OtelKeyValueMap& attributes, 39 | const std::unordered_map& carrier = {}) override; 40 | 41 | void PopulatePropagationHeaders( 42 | std::unordered_map& carrier) override; 43 | 44 | std::string ReturnCurrentSpanId() override; 45 | 46 | private: 47 | trace::SpanKind GetTraceSpanKind(const SpanKind& kind); 48 | 49 | protected: 50 | std::unique_ptr mSdkHelperFactory; 51 | AgentLogger mLogger; 52 | }; 53 | 54 | } //sdkwrapper 55 | } //core 56 | } //otel 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/src/nginx/ngx_http_opentelemetry_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include "ngx_http_opentelemetry_log.h" 19 | 20 | ngx_flag_t logState = false; 21 | 22 | /* This will log the error only when logState(traceAsError) flag is set by user*/ 23 | void ngx_writeTrace(ngx_log_t *log, const char* funcName, const char* format, ...) 24 | { 25 | char note[8192]; 26 | va_list args; 27 | 28 | va_start(args, format); 29 | vsnprintf(note, sizeof(note), format, args); 30 | va_end(args); 31 | 32 | if (logState && log) 33 | { 34 | ngx_log_error(NGX_LOG_ERR, log, 0, "mod_opentelemetry: %s: %s", funcName, note); 35 | } 36 | } 37 | 38 | /* This will always log the error irrespective of the logState(traceAsError) flag */ 39 | void ngx_writeError(ngx_log_t *log, const char* funcName, const char* format, ...) 40 | { 41 | char note[8192]; 42 | va_list args; 43 | 44 | va_start(args, format); 45 | vsnprintf(note, sizeof(note), format, args); 46 | va_end(args); 47 | 48 | if (log && funcName) 49 | { 50 | ngx_log_error(NGX_LOG_ERR, log, 0, "mod_opentelemetry: %s: %s", funcName, note); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/integration/src/test/java/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import com.google.gson.JsonArray; 4 | import org.json.JSONArray; 5 | import org.json.JSONObject; 6 | 7 | import java.util.Iterator; 8 | 9 | public class JsonUtils { 10 | 11 | public void validateComplexJson(JSONObject json, String key) { 12 | boolean exists = json.has(key); 13 | Iterator keys; 14 | String nextKeys; 15 | 16 | if(!exists) { 17 | keys = json.keys(); 18 | while(keys.hasNext()){ 19 | nextKeys = (String)keys.next(); 20 | try{ 21 | if(json.get(nextKeys) instanceof JSONObject) { 22 | if(!exists) { 23 | validateComplexJson(json.getJSONObject(nextKeys), key); 24 | } else if (json.get(nextKeys) instanceof JsonArray) { 25 | JSONArray jsonArray = json.getJSONArray(nextKeys); 26 | for(int i=0; i 22 | #include 23 | #include 24 | 25 | 26 | namespace otel { 27 | namespace core { 28 | namespace sdkwrapper { 29 | 30 | using SpanAttributeValue = opentelemetry::common::AttributeValue; 31 | using OtelKeyValueMap = std::unordered_map; 32 | using namespace opentelemetry; 33 | 34 | class IScopedSpan { 35 | public: 36 | virtual ~IScopedSpan() = default; 37 | 38 | virtual void End() = 0; 39 | 40 | virtual void AddEvent(const std::string& name, 41 | const std::chrono::system_clock::time_point &timePoint, 42 | const OtelKeyValueMap& attributes) = 0; 43 | 44 | virtual void AddAttribute(const std::string& key, 45 | const SpanAttributeValue& value) = 0; 46 | 47 | virtual void SetStatus(const StatusCode status, const std::string& desc = "") = 0; 48 | 49 | virtual SpanKind GetSpanKind() = 0; 50 | }; 51 | 52 | } //sdkwrapper 53 | } //core 54 | } //otel 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/test/unit/SdkUtils_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022, OpenTelemetry Authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "gtest/gtest.h" 17 | #include "sdkwrapper/SdkUtils.h" 18 | 19 | TEST(Get, ReturnsExpectedValueWhenKeyFound) 20 | { 21 | std::unordered_map carrier 22 | {{"TestKey", "TestValue"}}; 23 | opentelemetry::nostd::string_view key = "TestKey"; 24 | otel::core::sdkwrapper::OtelCarrier otelCarrier(carrier); 25 | auto value = otelCarrier.Get(key); 26 | EXPECT_EQ(value, "TestValue"); 27 | } 28 | 29 | TEST(Get, ReturnsEmptyWhenKeyNotFound) 30 | { 31 | std::unordered_map carrier 32 | {{"TestKey", "TestValue"}}; 33 | opentelemetry::nostd::string_view key = "TestKey1"; 34 | otel::core::sdkwrapper::OtelCarrier otelCarrier(carrier); 35 | auto value = otelCarrier.Get(key); 36 | EXPECT_EQ(value, ""); 37 | } 38 | 39 | TEST(Set, InsertsExpectedKeyAndValue) 40 | { 41 | std::unordered_map carrier; 42 | opentelemetry::nostd::string_view key = "TestKey"; 43 | opentelemetry::nostd::string_view value = "TestValue"; 44 | otel::core::sdkwrapper::OtelCarrier otelCarrier; 45 | otelCarrier.Set(key, value); 46 | EXPECT_EQ(otelCarrier.Get(key), value); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /examples/ffi/cpprust/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "cpprust/src/lib.rs.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static void BM_log_string_from_cpp_to_rust_log_crate(benchmark::State& state) { 8 | std::string message = "Test"; 9 | for (auto _ : state) { 10 | log_string_from_cpp_to_rust_log_crate(message); 11 | } 12 | } 13 | 14 | static void BM_log_int_from_cpp_to_rust_log_crate(benchmark::State& state) { 15 | int level = 1; 16 | 17 | for (auto _ : state) { 18 | log_int_from_cpp_to_rust_log_crate(level); 19 | } 20 | } 21 | 22 | static void BM_log_vector_from_cpp_to_rust_log_crate(benchmark::State& state) { 23 | std::vector names = {"Alice", "Bob", "Charlie"}; 24 | 25 | for (auto _ : state) { 26 | log_vector_from_cpp_to_rust_log_crate(names); 27 | } 28 | } 29 | 30 | static void BM_log_struct_from_cpp_to_rust_log_crate(benchmark::State& state) { 31 | Person p1; 32 | p1.name = "John"; 33 | p1.age = 30; 34 | 35 | for(auto _ : state) { 36 | log_struct_from_cpp_to_rust_log_crate(p1); 37 | } 38 | } 39 | 40 | static void BM_log_class_from_cpp_to_rust_log_crate(benchmark::State& state) { 41 | Animal dog(42); 42 | 43 | for(auto _ : state) { 44 | log_class_from_cpp_to_rust_log_crate(dog); 45 | } 46 | } 47 | 48 | BENCHMARK(BM_log_string_from_cpp_to_rust_log_crate); 49 | BENCHMARK(BM_log_int_from_cpp_to_rust_log_crate); 50 | BENCHMARK(BM_log_vector_from_cpp_to_rust_log_crate); 51 | BENCHMARK(BM_log_struct_from_cpp_to_rust_log_crate); 52 | BENCHMARK(BM_log_class_from_cpp_to_rust_log_crate); 53 | 54 | int main(int argc, char** argv) { 55 | init_rust_logger(); 56 | ::benchmark::Initialize(&argc, argv); 57 | ::benchmark::RunSpecifiedBenchmarks(); 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/opentelemetry_module.conf: -------------------------------------------------------------------------------- 1 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_common.so 2 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_resources.so 3 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_trace.so 4 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_otlp_recordable.so 5 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_exporter_ostream_span.so 6 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_exporter_otlp_grpc.so 7 | 8 | #Load the ApacheModule SDK 9 | LoadFile /opt/opentelemetry-webserver-sdk/sdk_lib/lib/libopentelemetry_webserver_sdk.so 10 | #Load the Apache Module. In this example for Apache 2.2 11 | LoadModule otel_apache_module /opt/opentelemetry-webserver-sdk/WebServerModule/Apache/libmod_apache_otel22.so 12 | ApacheModuleEnabled ON 13 | 14 | #ApacheModule Otel Exporter details 15 | ApacheModuleOtelSpanExporter otlp 16 | ApacheModuleOtelExporterEndpoint collector:4317 17 | #ApacheModuleOtelExporterHeaders api-key=abc123 18 | 19 | # SSL Certificates 20 | #ApacheModuleOtelSslEnabled ON 21 | #ApacheModuleOtelSslCertificatePath 22 | 23 | #ApacheModuleOtelSpanProcessor Batch 24 | #ApacheModuleOtelSampler AlwaysOn 25 | #ApacheModuleOtelMaxQueueSize 1024 26 | #ApacheModuleOtelScheduledDelayMillis 3000 27 | #ApacheModuleOtelExportTimeoutMillis 30000 28 | #ApacheModuleOtelMaxExportBatchSize 1024 29 | 30 | ApacheModuleServiceName DemoService 31 | ApacheModuleServiceNamespace DemoServiceNamespace 32 | ApacheModuleServiceInstanceId DemoInstanceId 33 | 34 | ApacheModuleResolveBackends ON 35 | ApacheModuleTraceAsError ON 36 | #ApacheModuleWebserverContext DemoService DemoServiceNamespace DemoInstanceId 37 | 38 | #ApacheModuleSegmentType custom 39 | #ApacheModuleSegmentParameter 15,1,6,7 40 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/generator/ninja_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Copyright (c) 2012 Google Inc. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """ Unit tests for the ninja.py file. """ 8 | 9 | import gyp.generator.ninja as ninja 10 | import unittest 11 | import StringIO 12 | import sys 13 | import TestCommon 14 | 15 | 16 | class TestPrefixesAndSuffixes(unittest.TestCase): 17 | def test_BinaryNamesWindows(self): 18 | writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', 19 | 'build.ninja', 'win') 20 | spec = { 'target_name': 'wee' } 21 | self.assertTrue(writer.ComputeOutputFileName(spec, 'executable'). 22 | endswith('.exe')) 23 | self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). 24 | endswith('.dll')) 25 | self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). 26 | endswith('.lib')) 27 | 28 | def test_BinaryNamesLinux(self): 29 | writer = ninja.NinjaWriter('foo', 'wee', '.', '.', 'build.ninja', '.', 30 | 'build.ninja', 'linux') 31 | spec = { 'target_name': 'wee' } 32 | self.assertTrue('.' not in writer.ComputeOutputFileName(spec, 33 | 'executable')) 34 | self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). 35 | startswith('lib')) 36 | self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). 37 | startswith('lib')) 38 | self.assertTrue(writer.ComputeOutputFileName(spec, 'shared_library'). 39 | endswith('.so')) 40 | self.assertTrue(writer.ComputeOutputFileName(spec, 'static_library'). 41 | endswith('.a')) 42 | 43 | if __name__ == '__main__': 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /exporters/user_events/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright The OpenTelemetry Authors 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | FROM ubuntu:latest 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | 7 | WORKDIR /work 8 | 9 | RUN apt update && apt install -y \ 10 | build-essential \ 11 | cmake \ 12 | git \ 13 | ninja-build \ 14 | protobuf-compiler \ 15 | libcurl4-openssl-dev \ 16 | libgtest-dev 17 | 18 | RUN cd /work && git clone --recursive --depth=1 https://github.com/google/googletest.git && \ 19 | cd googletest && mkdir build && cd build && \ 20 | cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug .. && \ 21 | ninja && ninja install 22 | 23 | RUN cd /work && \ 24 | git clone --recursive --depth=1 https://github.com/google/benchmark.git && \ 25 | cd benchmark && mkdir out && cd out && \ 26 | cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D BENCHMARK_DOWNLOAD_DEPENDENCIES=on .. && \ 27 | ninja && \ 28 | ninja install 29 | 30 | RUN cd /work && \ 31 | git clone --recursive --depth=1 https://github.com/nlohmann/json.git && \ 32 | cd json && mkdir build && cd build && \ 33 | cmake -G Ninja .. && \ 34 | ninja && \ 35 | ninja install 36 | 37 | RUN cd /work && \ 38 | git clone --recursive --depth=1 https://github.com/open-telemetry/opentelemetry-cpp.git && \ 39 | cd opentelemetry-cpp && \ 40 | mkdir build && cd build && \ 41 | cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=0 -D WITH_OTLP_HTTP=1 -D WITH_OTLP_GRPC=0 -D WITH_STL=CXX17 .. && \ 42 | ninja && \ 43 | ninja install 44 | 45 | RUN cd /work && \ 46 | git clone --recursive --depth=1 https://github.com/open-telemetry/opentelemetry-cpp-contrib 47 | 48 | RUN cd /work && \ 49 | cd opentelemetry-cpp-contrib/exporters/user_events && \ 50 | mkdir build && cd build && \ 51 | cmake -G Ninja -D CMAKE_BUILD_TYPE=Debug .. && \ 52 | ninja && \ 53 | ninja install 54 | -------------------------------------------------------------------------------- /instrumentation/otel-webserver-module/scripts/gyp/r1919/pylib/gyp/generator/gypsh.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2011 Google Inc. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | """gypsh output module 6 | 7 | gypsh is a GYP shell. It's not really a generator per se. All it does is 8 | fire up an interactive Python session with a few local variables set to the 9 | variables passed to the generator. Like gypd, it's intended as a debugging 10 | aid, to facilitate the exploration of .gyp structures after being processed 11 | by the input module. 12 | 13 | The expected usage is "gyp -f gypsh -D OS=desired_os". 14 | """ 15 | 16 | 17 | import code 18 | import sys 19 | 20 | 21 | # All of this stuff about generator variables was lovingly ripped from gypd.py. 22 | # That module has a much better description of what's going on and why. 23 | _generator_identity_variables = [ 24 | 'EXECUTABLE_PREFIX', 25 | 'EXECUTABLE_SUFFIX', 26 | 'INTERMEDIATE_DIR', 27 | 'PRODUCT_DIR', 28 | 'RULE_INPUT_ROOT', 29 | 'RULE_INPUT_DIRNAME', 30 | 'RULE_INPUT_EXT', 31 | 'RULE_INPUT_NAME', 32 | 'RULE_INPUT_PATH', 33 | 'SHARED_INTERMEDIATE_DIR', 34 | ] 35 | 36 | generator_default_variables = { 37 | } 38 | 39 | for v in _generator_identity_variables: 40 | generator_default_variables[v] = '<(%s)' % v 41 | 42 | 43 | def GenerateOutput(target_list, target_dicts, data, params): 44 | locals = { 45 | 'target_list': target_list, 46 | 'target_dicts': target_dicts, 47 | 'data': data, 48 | } 49 | 50 | # Use a banner that looks like the stock Python one and like what 51 | # code.interact uses by default, but tack on something to indicate what 52 | # locals are available, and identify gypsh. 53 | banner='Python %s on %s\nlocals.keys() = %s\ngypsh' % \ 54 | (sys.version, sys.platform, repr(sorted(locals.keys()))) 55 | 56 | code.interact(banner, local=locals) 57 | --------------------------------------------------------------------------------