pax_global_header00006660000000000000000000000064147441237140014521gustar00rootroot0000000000000052 comment=ced79860f8c8a091a2eabfee6d47783f828a9b59 opentelemetry-cpp-1.19.0/000077500000000000000000000000001474412371400152655ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.bazelignore000066400000000000000000000000261474412371400175650ustar00rootroot00000000000000third_party tools out opentelemetry-cpp-1.19.0/.bazelrc000066400000000000000000000034571474412371400167210ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # bazel configurations for running tests under sanitizers. # Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc # Enable automatic configs based on platform common --enable_platform_specific_config # Make globs that don't match anything fail common --incompatible_disallow_empty_glob # Needed by gRPC to build on some platforms. build --copt -DGRPC_BAZEL_BUILD # Workaround abseil libraries missing symbols build:windows --dynamic_mode=off # Set minimum supported C++ version build:macos --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 build:linux --host_cxxopt=-std=c++14 --cxxopt=-std=c++14 build:windows --host_cxxopt=/std:c++14 --cxxopt=/std:c++14 # --config=asan : Address Sanitizer. common:asan --copt -DADDRESS_SANITIZER 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 common:asan --copt -fsanitize-address-use-after-scope common:asan --copt -fno-sanitize-recover=all 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 common:asan --linkopt -fsanitize-address-use-after-scope common:asan --linkopt -fno-sanitize-recover=all common:asan --cc_output_directory_tag=asan # --config=tsan : Thread Sanitizer. common:tsan --copt -fsanitize=thread common:tsan --copt -DTHREAD_SANITIZER common:tsan --linkopt -fsanitize=thread common:tsan --cc_output_directory_tag=tsan # This is needed to address false positive problem with abseil.The same setting as gRPC # https://github.com/google/sanitizers/issues/953 common:tsan --test_env=TSAN_OPTIONS=report_atomic_races=0 opentelemetry-cpp-1.19.0/.bazelversion000066400000000000000000000000061474412371400177650ustar00rootroot000000000000007.1.1 opentelemetry-cpp-1.19.0/.clang-format000066400000000000000000000027151474412371400176450ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html BasedOnStyle: Chromium # Allow double brackets such as std::vector>. Standard: Cpp11 # Indent 2 spaces at a time. IndentWidth: 2 # Keep lines under 100 columns long. ColumnLimit: 100 # Always break before braces BreakBeforeBraces: Custom BraceWrapping: # TODO(lujc) wait for clang-format-9 support in Chromium tools # AfterCaseLabel: true AfterClass: true AfterControlStatement: true AfterEnum: true AfterFunction: true AfterNamespace: true AfterStruct: true AfterUnion: true BeforeCatch: true BeforeElse: true IndentBraces: false SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false # Keeps extern "C" blocks unindented. AfterExternBlock: false # Indent case labels. IndentCaseLabels: true # Right-align pointers and references PointerAlignment: Right # ANGLE likes to align things as much as possible. AlignOperands: true AlignConsecutiveAssignments: true # Use 2 space negative offset for access modifiers AccessModifierOffset: -2 # TODO(jmadill): Decide if we want this on. Doesn't have an "all or none" mode. AllowShortCaseLabelsOnASingleLine: false # Useful for spacing out functions in classes KeepEmptyLinesAtTheStartOfBlocks: true # Indent nested PP directives. IndentPPDirectives: AfterHash # Include blocks style IncludeBlocks: Preserve opentelemetry-cpp-1.19.0/.clang-tidy000066400000000000000000000025141474412371400173230ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 Checks: > -*, performance-*, portability-*, abseil-*, -abseil-string-find-str-contains, bugprone-*, -bugprone-easily-swappable-parameters, -bugprone-implicit-widening-of-multiplication-result, -bugprone-inc-dec-in-conditions, -bugprone-narrowing-conversions, -bugprone-unchecked-optional-access, -bugprone-unhandled-exception-at-new, -bugprone-unused-local-non-trivial-variable, google-*, -google-build-using-namespace, -google-default-arguments, -google-explicit-constructor, -google-readability-avoid-underscore-in-googletest-name, -google-readability-braces-around-statements, -google-readability-namespace-comments, -google-readability-todo, -google-runtime-references, misc-*, -misc-const-correctness, -misc-include-cleaner, -misc-non-private-member-variables-in-classes, -misc-unused-alias-decls, -misc-use-anonymous-namespace, cppcoreguidelines-*, -cppcoreguidelines-owning-memory, -cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-init-variables, -cppcoreguidelines-macro-usage, -cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-pro-*opentelemetry-cpp-1.19.0/.cmake-format.py000066400000000000000000000004141474412371400202620ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # If comment markup is enabled, don't reflow the first comment block in # eachlistfile. Use this to preserve formatting of your # copyright/licensestatements. first_comment_is_literal = True opentelemetry-cpp-1.19.0/.copyright-ignore000066400000000000000000000015161474412371400205620ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # Ignore the following directories ./.git/* ./.github/* ./third_party/benchmark/* ./third_party/boost/* ./third_party/googletest/* ./third_party/ms-gsl/* ./third_party/nlohmann-json/* ./third_party/opentelemetry-proto/* ./third_party/prometheus-cpp/* ./tools/vcpkg/* ./tools/ports/* # Third party code ./api/include/opentelemetry/nostd/internal/absl/* ./exporters/jaeger/thrift-gen/* ./exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h # Doc ./docs/* ## Ignore the following files patterns *.md *.rst *.png *.log *.patch *.json *.nuspec *.pem # Packaging */CONTROL # LICENSE files */LICENSE # Ignore the following misc files ./.bazelignore ./.bazelversion ./docker/.gitignore .markdownlintignore ./ci/toc.yml ./ci/valgrind-suppressions opentelemetry-cpp-1.19.0/.devcontainer/000077500000000000000000000000001474412371400200245ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.devcontainer/Dockerfile.dev000066400000000000000000000013771474412371400226030ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 FROM otel/cpp_format_tools ARG GRPC_VERSION=v1.55.0 ARG PROTOBUF_VERSION=23.4 ARG ABSEIL_CPP_VERSION=20240116.1 ENV PROTOBUF_VERSION=${PROTOBUF_VERSION} ENV ABSEIL_CPP_VERSION=${ABSEIL_CPP_VERSION} COPY ci /opt/ci RUN apt update && apt install -y wget \ ninja-build \ libcurl4-openssl-dev \ markdownlint RUN cd /opt/ci && bash setup_cmake.sh RUN cd /opt/ci && bash setup_ci_environment.sh RUN cd /opt && bash ci/setup_googletest.sh \ && bash ci/setup_grpc.sh -r ${GRPC_VERSION} ADD https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-linux-amd64 /usr/local/bin RUN git config --global core.autocrlf input \ && chmod +x /usr/local/bin/bazelisk-linux-amd64 opentelemetry-cpp-1.19.0/.devcontainer/devcontainer.json000066400000000000000000000012671474412371400234060ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/javascript-node { "name": "opentelemetry-cpp", "build": { "context": "..", "dockerfile": "Dockerfile.dev", "args": { "GRPC_VERSION": "v1.55.0", "PROTOBUF_VERSION": "23.4", "ABSEIL_CPP_VERSION":"20240116.1" } }, "settings": { "terminal.integrated.shell.linux": "/bin/sh" }, "extensions": [ "ms-vscode.cpptools", "ms-azuretools.vscode-docker", "ms-vscode.cpptools-extension-pack" ], "remoteUser": "root" } opentelemetry-cpp-1.19.0/.gitattributes000066400000000000000000000024071474412371400201630ustar00rootroot00000000000000##### Source code ##### ## C++ and C source files *.c text eol=lf diff=cpp *.h text eol=lf diff=cpp *.cc text eol=lf diff=cpp *.cpp text eol=lf diff=cpp *.cxx text eol=lf diff=cpp *.hpp text eol=lf diff=cpp ## Python scripts *.py text eol=lf diff=python ## Perl scripts/libraries/modules *.perl text eol=lf diff=perl *.pl text eol=lf diff=perl *.pm text eol=lf diff=perl ## Shell scripts *.sh text eol=lf *.bash text eol=lf ## Windows batch and PowerShell scripts *.bat text eol=crlf *.cmd text eol=crlf *.ps1 text eol=crlf ##### Other file types ##### ## Text files and documentation *.txt text README* text INSTALL* text LICENSE* text ## Non-text documentation *.html text diff=html *.pdf binary *.rtf binary ## git files .gitignore text eol=lf .gitattributes text eol=lf ## bazel files WORKSPACE text eol=lf BUILD text eol=lf opentelemetry-cpp-1.19.0/.github/000077500000000000000000000000001474412371400166255ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.github/.codecov.yaml000066400000000000000000000015561474412371400212200ustar00rootroot00000000000000codecov: require_ci_to_pass: false max_report_age: off coverage: precision: 2 round: up range: "80...100" status: project: default: informational: true target: auto threshold: 10% patch: false parsers: gcov: branch_detection: conditional: yes loop: yes method: no macro: no comment: layout: "reach,diff,flags,tree" behavior: default require_changes: false # Relative file path fixing. # CI file paths must match Git file paths. # This fix removes the "/home/runner/" prefix # to coverage report file paths. fixes: - "/home/runner/::" ignore: - "docs/**/*" - "docker/**/*" - "examples/**/*" - "bazel/**/*" - "cmake/**/*" - "buildscripts/**/*" - "third_party/**/*" - "test_common/**/*" - "tools/**/*" - ".vscode/**/*" - ".github/**/*" - "**/test/**/*" - "**.md"opentelemetry-cpp-1.19.0/.github/CODEOWNERS000066400000000000000000000004431474412371400202210ustar00rootroot00000000000000# Code owners file. # This file controls who is tagged for review for any given pull request. # For ETW exporter exporters/etw/* @reyang @maxgolov @lalitb @ThomsonTan @open-telemetry/cpp-approvers # For anything not explicitly taken by someone else: * @open-telemetry/cpp-approvers opentelemetry-cpp-1.19.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001474412371400210105ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000013031474412371400234770ustar00rootroot00000000000000--- name: Bug Report about: Create a report to help us improve labels: bug --- **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. **Steps to reproduce** Describe exactly how to reproduce the error. Include a code sample if applicable. **What is the expected behavior?** What did you expect to see? **What is the actual behavior?** What did you see instead? **Additional context** Add any other context about the problem here. opentelemetry-cpp-1.19.0/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000014661474412371400245440ustar00rootroot00000000000000--- name: Feature Request about: Suggest an idea for this project labels: feature-request --- 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. **Is your feature request related to a problem?** If so, provide a concise description of the problem. **Describe the solution you'd like** What do you want to happen instead? What is the expected behavior? **Describe alternatives you've considered** Which alternative solutions or features have you considered? **Additional context** Add any other context about the feature request here. opentelemetry-cpp-1.19.0/.github/dependabot.yml000066400000000000000000000003551474412371400214600ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" labels: - "GHA" - package-ecosystem: "devcontainers" directory: "/" schedule: interval: daily opentelemetry-cpp-1.19.0/.github/pull_request_template.md000066400000000000000000000004501474412371400235650ustar00rootroot00000000000000Fixes # (issue) ## Changes Please provide a brief description of the changes here. For significant contributions please make sure you have completed the following items: * [ ] `CHANGELOG.md` updated for non-trivial changes * [ ] Unit tests have been added * [ ] Changes in public API reviewedopentelemetry-cpp-1.19.0/.github/repository-settings.md000066400000000000000000000022011474412371400232170ustar00rootroot00000000000000# Process This file documents local admin changes for opentelemetry-cpp, per the community process: https://github.com/open-telemetry/community/blob/main/docs/how-to-configure-new-repository.md Please note that the EasyCLA check **MUST** stay **REQUIRED**, it should never be disabled or bypassed, at the risk of tainting the repository. # Guidelines The best is to open a PR first that describes the change, so it can be discussed during review (maybe it is not needed, maybe there is an alternate solution, ...). The PR must add a log entry in this file, detailing: * the date the change is implemented * what is changed exactly (which setting) * a short rationale Admin changes are then applied only when the PR is merged. If for some reason a change is implemented in emergency, before a PR can be discussed and merged, a PR should still be prepared and pushed after the fact to describe the settings changed. # Log of local changes ## 2023-11-03 Created log file `.github/repository-settings.md`, since admin permissions are now granted to maintainers. See https://github.com/open-telemetry/community/issues/1727 No setting changed. opentelemetry-cpp-1.19.0/.github/workflows/000077500000000000000000000000001474412371400206625ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.github/workflows/benchmark.yml000066400000000000000000000041021474412371400233340ustar00rootroot00000000000000name: OpenTelemetry-cpp benchmarks on: push: branches: - main permissions: contents: write deployments: write jobs: benchmark: name: Run OpenTelemetry-cpp benchmarks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_benchmark - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: Run benchmark id: run_benchmarks run: | ./ci/do_ci.sh bazel.benchmark mkdir -p benchmarks mv api-benchmark_result.json benchmarks mv sdk-benchmark_result.json benchmarks mv exporters-benchmark_result.json benchmarks - uses: actions/upload-artifact@v4 with: name: benchmark_results path: benchmarks store_benchmark: needs: benchmark strategy: matrix: components: ["api", "sdk", "exporters"] name: Store benchmark result runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@master with: name: benchmark_results path: benchmarks - name: Print json files id: print_json run: | cat benchmarks/* - name: Push benchmark result uses: benchmark-action/github-action-benchmark@v1 with: name: OpenTelemetry-cpp ${{ matrix.components }} Benchmark tool: 'googlecpp' output-file-path: benchmarks/${{ matrix.components }}-benchmark_result.json github-token: ${{ secrets.GITHUB_TOKEN }} auto-push: true # Show alert with commit comment on detecting possible performance regression alert-threshold: '200%' comment-on-alert: true fail-on-alert: false gh-pages-branch: gh-pages benchmark-data-dir-path: benchmarks opentelemetry-cpp-1.19.0/.github/workflows/ci.yml000066400000000000000000000643671474412371400220200ustar00rootroot00000000000000name: CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: # Commented 2024-11-06, lack of workers in github causes CI failures # arm64_test: # name: CMake test arm64 (with modern protobuf,grpc and abseil) # runs-on: actuated-arm64-4cpu-16gb # steps: # - uses: actions/checkout@v4 # with: # submodules: 'recursive' # - name: setup # env: # PROTOBUF_VERSION: '23.3' # ABSEIL_CPP_VERSION: '20230125.3' # CXX_STANDARD: '14' # CC: /usr/bin/gcc-10 # CXX: /usr/bin/g++-10 # run: | # sudo -E ./ci/setup_gcc10.sh # sudo -E ./ci/setup_cmake.sh # sudo -E ./ci/setup_ci_environment.sh # sudo -E ./ci/setup_googletest.sh # sudo -E ./ci/install_abseil.sh # sudo -E ./ci/install_protobuf.sh # - name: run otlp exporter tests # env: # CC: /usr/bin/gcc-10 # CXX: /usr/bin/g++-10 # WITH_ABSEIL: 'ON' # CXX_STANDARD: '14' # run: | # sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp # ./ci/do_ci.sh cmake.exporter.otprotocol.test cmake_test: name: CMake test (without otlp-exporter) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run cmake tests (without otlp-exporter) env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | ./ci/do_ci.sh cmake.test cmake_gcc_maintainer_sync_test: name: CMake gcc 14 (maintainer mode, sync) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-14 CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: run cmake gcc (maintainer mode, sync) env: CC: /usr/bin/gcc-14 CXX: /usr/bin/g++-14 run: | ./ci/do_ci.sh cmake.maintainer.sync.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_gcc_maintainer_async_test: name: CMake gcc 14 (maintainer mode, async) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-14 CXX: /usr/bin/g++-14 PROTOBUF_VERSION: 21.12 run: | sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: run cmake gcc (maintainer mode, async) env: CC: /usr/bin/gcc-14 CXX: /usr/bin/g++-14 run: | ./ci/do_ci.sh cmake.maintainer.async.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_sync_test: name: CMake clang 18 (maintainer mode, sync) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: run cmake clang (maintainer mode, sync) env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.sync.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_async_test: name: CMake clang 18 (maintainer mode, async) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: run cmake clang (maintainer mode, async) env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.async.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_clang_maintainer_abiv2_test: name: CMake clang 18 (maintainer mode, abiv2) runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 PROTOBUF_VERSION: 21.12 run: | sudo apt remove needrestart #refer: https://github.com/actions/runner-images/issues/9937 sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: run cmake clang (maintainer mode, abiv2) env: CC: /usr/bin/clang-18 CXX: /usr/bin/clang++-18 run: | ./ci/do_ci.sh cmake.maintainer.abiv2.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_msvc_maintainer_test: name: CMake msvc (maintainer mode) runs-on: windows-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 - name: run tests run: ./ci/do_ci.ps1 cmake.maintainer.test cmake_msvc_maintainer_test_stl_cxx20: name: CMake msvc (maintainer mode) with C++20 runs-on: windows-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 - name: run tests env: CXX_STANDARD: '20' run: ./ci/do_ci.ps1 cmake.maintainer.cxx20.stl.test cmake_with_async_export_test: name: CMake test (without otlp-exporter and with async export) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run cmake tests (without otlp-exporter) env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | ./ci/do_ci.sh cmake.with_async_export.test cmake_abseil_stl_test: name: CMake test (with abseil) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run cmake tests (enable abseil-cpp) run: | sudo ./ci/install_abseil.sh ./ci/do_ci.sh cmake.abseil.test cmake_opentracing_shim_test: name: CMake test (with opentracing-shim) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run cmake tests (enable opentracing-shim) run: ./ci/do_ci.sh cmake.opentracing_shim.test cmake_test_cxx14_gcc: name: CMake C++14 test(GCC) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests (enable stl) env: CXX_STANDARD: '14' run: ./ci/do_ci.sh cmake.c++14.stl.test cmake_test_cxx17_gcc: name: CMake C++17 test(GCC) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests (enable stl) env: CXX_STANDARD: '17' run: ./ci/do_ci.sh cmake.c++17.stl.test cmake_test_cxx20_gcc: name: CMake C++20 test(GCC) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests env: CXX_STANDARD: '20' run: ./ci/do_ci.sh cmake.c++20.test - name: run tests (enable stl) env: CXX_STANDARD: '20' run: ./ci/do_ci.sh cmake.c++20.stl.test cmake_test_cxx20_clang: name: CMake C++20 test(Clang with libc++) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" CXX_STANDARD: '20' run: ./ci/do_ci.sh cmake.c++20.test - name: run tests (enable stl) env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" CXX_STANDARD: '20' run: ./ci/do_ci.sh cmake.c++20.stl.test cmake_test_cxx23_gcc: name: CMake C++23 test(GCC) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests env: CXX_STANDARD: '23' run: ./ci/do_ci.sh cmake.c++23.test - name: run tests (enable stl) env: CXX_STANDARD: '23' run: ./ci/do_ci.sh cmake.c++23.stl.test cmake_test_cxx23_clang: name: CMake C++23 test(Clang with libc++) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" run: | sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/setup_googletest.sh - name: run tests env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" CXX_STANDARD: '23' run: ./ci/do_ci.sh cmake.c++23.test - name: run tests (enable stl) env: CC: /usr/bin/clang CXX: /usr/bin/clang++ CXXFLAGS: "-stdlib=libc++" CXX_STANDARD: '23' run: ./ci/do_ci.sh cmake.c++23.stl.test cmake_otprotocol_test: name: CMake test (with otlp-exporter) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run otlp exporter tests run: | sudo ./ci/setup_grpc.sh ./ci/do_ci.sh cmake.exporter.otprotocol.test - name: generate test cert env: CFSSL_VERSION: 1.6.3 run: | sudo -E ./tools/setup-cfssl.sh (cd ./functional/cert; ./generate_cert.sh) - name: run func test run: | (cd ./functional/otlp; ./run_test.sh) cmake_modern_protobuf_grpc_with_abseil_test: name: CMake test (with modern protobuf,grpc and abseil) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: PROTOBUF_VERSION: '23.3' ABSEIL_CPP_VERSION: '20230125.3' CXX_STANDARD: '14' run: | sudo ./ci/setup_googletest.sh sudo ./ci/setup_ci_environment.sh sudo -E ./ci/install_abseil.sh sudo -E ./ci/install_protobuf.sh - name: run otlp exporter tests env: WITH_ABSEIL: 'ON' CXX_STANDARD: '14' run: | sudo -E ./ci/setup_grpc.sh -m -p protobuf -p abseil-cpp ./ci/do_ci.sh cmake.exporter.otprotocol.test cmake_do_not_install_test: name: CMake do not install test (with otlp-exporter) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run otlp exporter tests run: | sudo ./ci/setup_grpc.sh ./ci/do_ci.sh cmake.do_not_install.test cmake_otprotocol_shared_libs_with_static_grpc_test: name: CMake test (build shared libraries with otlp-exporter and static gRPC) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run otlp exporter tests run: | sudo ./ci/setup_grpc.sh -T ./ci/do_ci.sh cmake.exporter.otprotocol.shared_libs.with_static_grpc.test cmake_install_test: name: CMake install test (with abseil) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run cmake install (with abseil) run: | sudo ./ci/install_abseil.sh ./ci/do_ci.sh cmake.install.test - name: verify packages run: | ./ci/verify_packages.sh plugin_test: name: Plugin -> CMake runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run tests env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: ./ci/do_ci.sh cmake.test_example_plugin bazel_test: name: Bazel runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_test - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.test bazel_no_bzlmod_test: name: Bazel without bzlmod runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_test - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.no_bzlmod.test bazel_test_async: name: Bazel with async export runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_test - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.with_async_export.test bazel_valgrind: name: Bazel valgrind runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_valgrind - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.valgrind bazel_noexcept: name: Bazel noexcept runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_noexcept - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.noexcept bazel_nortti: name: Bazel nortti runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_nortti - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.nortti bazel_asan: name: Bazel asan config runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_asan - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.asan bazel_tsan: name: Bazel tsan config runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_tsan - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: ./ci/do_ci.sh bazel.tsan bazel_osx: name: Bazel on MacOS runs-on: macos-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /Users/runner/.cache/bazel key: bazel_osx - name: run tests run: ./ci/do_ci.sh bazel.macos.test benchmark: name: Benchmark runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Mount Bazel Cache uses: actions/cache@v4 env: cache-name: bazel_cache with: path: /home/runner/.cache/bazel key: bazel_benchmark - name: setup run: | sudo ./ci/setup_ci_environment.sh sudo ./ci/install_bazelisk.sh - name: run tests run: | env BENCHMARK_DIR=/benchmark ./ci/do_ci.sh benchmark - name: Upload benchmark results uses: actions/upload-artifact@v4 with: name: benchmark_reports path: /home/runner/benchmark format: name: Format runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: setup run: sudo apt remove needrestart && sudo ./ci/install_format_tools.sh #refer: https://github.com/actions/runner-images/issues/9937 - name: run tests run: ./ci/do_ci.sh format copyright: name: Copyright runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - name: check copyright run: ./tools/check_copyright.sh windows: name: CMake -> exporter proto runs-on: windows-2019 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 ./ci/install_windows_protobuf.ps1 - name: run cmake test run: ./ci/do_ci.ps1 cmake.test - name: run otprotocol test run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.test windows-build-dll: name: CMake -> exporter proto (Build as DLL) runs-on: windows-2019 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 ./ci/install_windows_protobuf.ps1 - name: run cmake test (DLL build) run: ./ci/do_ci.ps1 cmake.dll.test - name: run cmake cxx20 test (DLL build) run: ./ci/do_ci.ps1 cmake.dll.cxx20.test - name: run otprotocol test (DLL build) run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.dll.test windows_with_async_export: name: CMake (With async export) -> exporter proto runs-on: windows-2019 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 ./ci/install_windows_protobuf.ps1 - name: run cmake test run: ./ci/do_ci.ps1 cmake.with_async_export.test - name: run otprotocol test run: ./ci/do_ci.ps1 cmake.exporter.otprotocol.with_async_export.test windows_bazel: name: Bazel Windows runs-on: windows-2019 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/install_windows_bazelisk.ps1 - name: run tests run: ./ci/do_ci.ps1 bazel.build windows_plugin_test: name: Plugin -> CMake Windows runs-on: windows-2019 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup run: | ./ci/setup_windows_ci_environment.ps1 - name: run tests run: ./ci/do_ci.ps1 cmake.test_example_plugin code_coverage: name: Code coverage runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-10 CXX: /usr/bin/g++-10 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run tests and generate report env: CC: /usr/bin/gcc-10 CXX: /usr/bin/g++-10 run: ./ci/do_ci.sh code.coverage - name: upload report uses: codecov/codecov-action@v5 with: files: /home/runner/build/coverage.info markdown-lint: runs-on: ubuntu-latest steps: - name: check out code uses: actions/checkout@v4 - name: install markdownlint-cli run: sudo npm install -g markdownlint-cli - name: run markdownlint run: markdownlint . shellcheck: runs-on: ubuntu-latest steps: - name: check out code uses: actions/checkout@v4 - name: install shellcheck run: sudo apt install --assume-yes shellcheck - name: run shellcheck run: find . -name \*.sh | xargs shellcheck --severity=error misspell: runs-on: ubuntu-latest steps: - name: check out code uses: actions/checkout@v4 - name: install misspell run: | curl -L -o ./install-misspell.sh https://git.io/misspell sh ./install-misspell.sh - name: run misspell run: ./bin/misspell -error . docfx_check: name: DocFX check runs-on: windows-latest steps: - uses: actions/checkout@v4 - name: install docfx run: choco install docfx -y --version=2.58.5 - name: run ./ci/docfx.cmd shell: cmd run: ./ci/docfx.cmd w3c_trace_context_compliance_v1: name: W3C Distributed Tracing Validation V1 runs-on: ubuntu-latest steps: - name: Checkout open-telemetry/opentelemetry-cpp uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: run w3c trace-context test server (background) env: CXX_STANDARD: '14' run: | ./ci/do_ci.sh cmake.w3c.trace-context.build-server cd $HOME/build/ext/test/w3c_tracecontext_http_test_server ./w3c_tracecontext_http_test_server & - name: Checkout w3c/trace-context repo uses: actions/checkout@v4 with: repository: w3c/trace-context path: trace-context - name: install dependencies run: | sudo apt update && sudo apt install python3-pip sudo pip3 install aiohttp - name: run w3c trace-context test suite env: SPEC_LEVEL: 1 run: | python ${GITHUB_WORKSPACE}/trace-context/test/test.py http://localhost:30000/test TraceContextTest AdvancedTest curl http://localhost:30000/stop opentelemetry-cpp-1.19.0/.github/workflows/clang-tidy.yaml000066400000000000000000000044441474412371400236070ustar00rootroot00000000000000name: clang-tidy on: push: branches: [main] pull_request: branches: [main] jobs: clang-tidy: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Setup Environment env: PROTOBUF_VERSION: '23.3' ABSEIL_CPP_VERSION: '20230125.3' CXX_STANDARD: '14' run: | sudo apt update -y sudo apt install -y --no-install-recommends --no-install-suggests \ build-essential \ iwyu \ cmake \ libssl-dev \ libcurl4-openssl-dev \ libprotobuf-dev \ protobuf-compiler \ libgmock-dev \ libgtest-dev \ libbenchmark-dev if ! command -v clang-tidy &> /dev/null; then echo "clang-tidy could not be found" exit 1 fi echo "Using clang-tidy version: $(clang-tidy --version)" echo "clang-tidy installed at: $(which clang-tidy)" - name: Prepare CMake env: CC: clang CXX: clang++ run: | echo "Running cmake..." cmake -B build \ -DCMAKE_CXX_STANDARD=14 \ -DWITH_STL=CXX14 \ -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_FILE=ON \ -DWITH_PROMETHEUS=ON \ -DWITH_ZIPKIN=ON \ -DWITH_ELASTICSEARCH=ON \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ -DWITH_EXAMPLES=ON \ -DWITH_EXAMPLES_HTTP=ON \ -DBUILD_W3CTRACECONTEXT_TEST=ON \ -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ -DWITH_ASYNC_EXPORT_PREVIEW=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - name: Run clang-tidy run: | cmake --build build --target opentelemetry_proto jq -r .[].file build/compile_commands.json | grep -vE '/(generated|third_party)/' | xargs -P $(nproc) -n 1 clang-tidy --quiet -p build 2>&1 | tee -a clang-tidy.log - uses: actions/upload-artifact@v4 with: name: Logs (clang-tidy) path: ./clang-tidy.log - name: Count warnings run: | COUNT=$(grep -c "warning:" clang-tidy.log) echo "clang-tidy reported ${COUNT} warning(s)" # TODO: include WITH_OTLP_GRPC and WITH_ABSEIL flags. opentelemetry-cpp-1.19.0/.github/workflows/codeql-analysis.yml000066400000000000000000000015671474412371400245060ustar00rootroot00000000000000name: "CodeQL" on: push: branches: [main] pull_request: # The branches below must be a subset of the branches above branches: [main] jobs: CodeQL-Build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: submodules: 'recursive' - name: Remove Third_party Modules from Code Scan run: | rm -rf third_party - name: Setup env: CC: /usr/bin/gcc-12 CXX: /usr/bin/g++-12 GOOGLETEST_VERSION: 1.12.1 run: | sudo -E ./ci/setup_googletest.sh sudo -E ./ci/setup_ci_environment.sh - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: cpp - name: Autobuild uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 opentelemetry-cpp-1.19.0/.github/workflows/cppcheck.yml000066400000000000000000000040361474412371400231700ustar00rootroot00000000000000 name: cppcheck on: push: branches: [ main ] pull_request: branches: [ main ] jobs: cppcheck: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Set up dependencies run: | sudo apt update -y sudo apt install -y cppcheck - name: Run cppcheck run: | cppcheck --version | tee cppcheck.log cppcheck \ --force \ --enable=warning,performance,portability \ --inline-suppr \ --suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \ --language=c++ \ --std=c++14 \ -I api/include \ -I exporters/elasticsearch/include \ -I exporters/etw/include \ -I exporters/memory/include \ -I exporters/ostream/include \ -I exporters/otlp/include \ -I exporters/prometheus/include \ -I exporters/zipkin/include \ -I ext/include \ -I opentracing-shim/include \ -I sdk/include \ -i build \ -i test \ -i third_party \ -j $(nproc) \ . 2>&1 | tee --append cppcheck.log - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Logs (cppcheck) path: ./cppcheck.log - name: Count warnings run: | set +e readonly WARNING_COUNT=`grep -c -E "\[.+\]" cppcheck.log` echo "cppcheck reported ${WARNING_COUNT} warning(s)" # Acceptable limit, to decrease over time down to 0 readonly WARNING_LIMIT=10 # FAIL the build if WARNING_COUNT > WARNING_LIMIT if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then exit 1 # WARN in annotations if WARNING_COUNT > 0 elif [ $WARNING_COUNT -gt 0 ] ; then echo "::warning::cppcheck reported ${WARNING_COUNT} warning(s)" fi opentelemetry-cpp-1.19.0/.github/workflows/dependencies_image.yml000066400000000000000000000021241474412371400251740ustar00rootroot00000000000000name: 'OpenTelemetry-cpp dependencies image' on: schedule: - cron: "0 3 * * 6" jobs: docker_image: name: Docker Image runs-on: ubuntu-latest timeout-minutes: 300 steps: - name: checkout uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 - name: Build Image uses: docker/build-push-action@v6 with: builder: ${{ steps.buildx.outputs.name }} context: ci/ file: ./docker/Dockerfile build-args: BASE_IMAGE=ubuntu:latest platforms: linux/amd64 # platforms: linux/amd64,linux/arm64 push: false tags: otel-cpp-deps load: true - name: Save Image run: | docker images docker save -o /opt/otel-cpp-deps-debian.tar otel-cpp-deps - name: Upload Image uses: actions/upload-artifact@v4 with: name: otel-cpp-deps path: /opt/otel-cpp-deps-debian.tar retention-days: 14 opentelemetry-cpp-1.19.0/.github/workflows/iwyu.yml000066400000000000000000000046121474412371400224050ustar00rootroot00000000000000 name: include-what-you-use on: push: branches: [ main ] pull_request: branches: [ main ] jobs: iwyu: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: 'recursive' - name: setup dependencies run: | sudo apt update -y sudo apt install -y --no-install-recommends --no-install-suggests \ build-essential \ iwyu \ cmake \ ninja-build \ libssl-dev \ libcurl4-openssl-dev \ libprotobuf-dev \ protobuf-compiler \ libgmock-dev \ libgtest-dev \ libbenchmark-dev - name: setup grpc run: | sudo ./ci/setup_grpc.sh - name: Prepare CMake run: | TOPDIR=`pwd` mkdir build && cd build CC="clang" CXX="clang++" cmake \ -DCMAKE_CXX_STANDARD=14 \ -DWITH_STL=CXX14 \ -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="include-what-you-use;-w;-Xiwyu;--mapping_file=${TOPDIR}/.iwyu.imp;" \ -DBUILD_TESTING=ON \ -DBUILD_W3CTRACECONTEXT_TEST=ON \ -DWITH_OTLP_GRPC=ON \ -DWITH_OTLP_HTTP=ON \ -DWITH_OTLP_FILE=ON \ -DWITH_OPENTRACING=ON \ -DWITH_OTLP_HTTP_COMPRESSION=ON \ -DWITH_THREAD_INSTRUMENTATION=ON \ -DWITH_ZIPKIN=ON \ -DWITH_PROMETHEUS=ON \ .. - name: iwyu_tool run: | cd build make -k 2>&1 | tee -a iwyu.log - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Logs (include-what-you-use) path: ./build/*.log - name: count warnings run: | set +e cd build readonly WARNING_COUNT=`grep -c "include-what-you-use reported diagnostics:" iwyu.log` echo "include-what-you-use reported ${WARNING_COUNT} warning(s)" # Acceptable limit, to decrease over time down to 0 readonly WARNING_LIMIT=0 # FAIL the build if WARNING_COUNT > WARNING_LIMIT if [ $WARNING_COUNT -gt $WARNING_LIMIT ] ; then exit 1 # WARN in annotations if WARNING_COUNT > 0 elif [ $WARNING_COUNT -gt 0 ] ; then echo "::warning::include-what-you-use reported ${WARNING_COUNT} warning(s)" fi opentelemetry-cpp-1.19.0/.github/workflows/project_management_comment.yml000066400000000000000000000011261474412371400267710ustar00rootroot00000000000000 name: Add comment on: issues: types: - labeled jobs: add-comment: if: github.event.label.name == 'help wanted' runs-on: ubuntu-latest permissions: issues: write steps: - name: Add comment uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 with: issue-number: ${{ github.event.issue.number }} body: | This issue is available for anyone to work on. **Make sure to reference this issue in your pull request.** :sparkles: Thank you for your contribution! :sparkles: opentelemetry-cpp-1.19.0/.github/workflows/project_management_issue_open.yml000066400000000000000000000007461474412371400275070ustar00rootroot00000000000000name: OpenTelemetry-cpp project on: issues: types: - reopened - opened jobs: label_issues: runs-on: ubuntu-latest permissions: issues: write steps: - uses: actions/github-script@v7 with: script: | github.rest.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, labels: ["needs-triage"] }) opentelemetry-cpp-1.19.0/.github/workflows/stale.yml000066400000000000000000000005631474412371400225210ustar00rootroot00000000000000name: "Mark stale issues" on: schedule: - cron: "30 1 * * *" jobs: stale: runs-on: ubuntu-latest steps: - uses: actions/stale@v9 with: stale-issue-message: "This issue was marked as stale due to lack of activity." days-before-issue-stale: 60 days-before-close: -1 exempt-issue-labels: "do-not-stale" opentelemetry-cpp-1.19.0/.gitignore000066400000000000000000000025431474412371400172610ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore # Prerequisites *.d # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll *.pdb # Fortran module files *.mod *.smod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app # Bazel files MODULE.bazel.lock /bazel-* # Mac .DS_Store # Output directories /out /out.* # Indicator that the tools were deployed .buildtools # Temporary Bazel directories /bazel-* /plugin /build tags .cache/clangd/* # Temporary dir used when generating semconv buildscripts/semantic-convention/tmp-semconv/ # Generated cert keys in functional tests functional/cert/ca.csr functional/cert/ca.pem functional/cert/ca-key.pem functional/cert/client_cert.csr functional/cert/client_cert.pem functional/cert/client_cert-key.pem functional/cert/server_cert.csr functional/cert/server_cert.pem functional/cert/server_cert-key.pem functional/cert/ca_b.csr functional/cert/ca_b.pem functional/cert/ca_b-key.pem functional/cert/client_cert_b.csr functional/cert/client_cert_b.pem functional/cert/client_cert_b-key.pem functional/cert/server_cert_b.csr functional/cert/server_cert_b.pem functional/cert/server_cert_b-key.pem functional/cert/unreadable.pem opentelemetry-cpp-1.19.0/.gitmodules000066400000000000000000000020211474412371400174350ustar00rootroot00000000000000[submodule "third_party/prometheus-cpp"] path = third_party/prometheus-cpp url = https://github.com/jupp0r/prometheus-cpp branch = master [submodule "tools/vcpkg"] path = tools/vcpkg url = https://github.com/Microsoft/vcpkg branch = master [submodule "third_party/ms-gsl"] path = third_party/ms-gsl url = https://github.com/microsoft/GSL branch = main [submodule "third_party/googletest"] path = third_party/googletest url = https://github.com/google/googletest branch = main [submodule "third_party/benchmark"] path = third_party/benchmark url = https://github.com/google/benchmark branch = main [submodule "third_party/opentelemetry-proto"] path = third_party/opentelemetry-proto url = https://github.com/open-telemetry/opentelemetry-proto branch = main [submodule "third_party/nlohmann-json"] path = third_party/nlohmann-json url = https://github.com/nlohmann/json branch = master [submodule "third_party/opentracing-cpp"] path = third_party/opentracing-cpp url = https://github.com/opentracing/opentracing-cpp.git branch = master opentelemetry-cpp-1.19.0/.iwyu.imp000066400000000000000000000025701474412371400170530ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # include-what-you-use mapping file [ # Work around for C++ STL { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, # Local opentelemetry-cpp style # We prefer to include for simplicity { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, # We prefer to include for simplicity { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, ] opentelemetry-cpp-1.19.0/.markdownlint.json000066400000000000000000000001501474412371400207430ustar00rootroot00000000000000{ "default": true, "MD013": { "code_blocks": false, "tables": false } } opentelemetry-cpp-1.19.0/.markdownlintignore000066400000000000000000000000601474412371400211770ustar00rootroot00000000000000third_party/** tools/** examples/otlp/README.md opentelemetry-cpp-1.19.0/.vscode/000077500000000000000000000000001474412371400166265ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/.vscode/launch.json000066400000000000000000000012171474412371400207740ustar00rootroot00000000000000{ "version": "0.2.0", "configurations": [ { "name": "Debug on Windows", "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/build/", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false }, { "name": "Debug on Linux", "type": "gdb", "request": "launch", "target": "${workspaceFolder}/bazel-bin/", "cwd": "${workspaceRoot}", "valuesFormatting": "parseText" } ] } opentelemetry-cpp-1.19.0/CHANGELOG.md000066400000000000000000004172551474412371400171140ustar00rootroot00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Guideline to update the version Increment the: * MAJOR version when you make incompatible API/ABI changes, * MINOR version when you add functionality in a backwards compatible manner, and * PATCH version when you make backwards compatible bug fixes. ## [Unreleased] ## [1.19 2025-01-22] * [PROMETHEUS_EXPORTER] Fix default for emitting otel_scope attributes [#3171](https://github.com/open-telemetry/opentelemetry-cpp/pull/3171) * [Code health] Include what you use cleanup, part 5 [#3140](https://github.com/open-telemetry/opentelemetry-cpp/pull/3140) * [BUILD] Upgrade cmake [#3167](https://github.com/open-telemetry/opentelemetry-cpp/pull/3167) * [SHIM] Fix string_view mappings between OT and OTel [#3181](https://github.com/open-telemetry/opentelemetry-cpp/pull/3181) * [EXPORTER] Refactor ElasticSearchRecordable [#3164](https://github.com/open-telemetry/opentelemetry-cpp/pull/3164) * [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.29.0 [#3182](https://github.com/open-telemetry/opentelemetry-cpp/pull/3182) * [BUILD] Fix cross-compilation with protoc [#3186](https://github.com/open-telemetry/opentelemetry-cpp/pull/3186) * [Code health] Perform cppcheck cleanup [#3150](https://github.com/open-telemetry/opentelemetry-cpp/pull/3150) * [EXPORTER] add instrumentation scope attributes to otlp proto messages for traces and metrics [#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185) * [SDK] Tracer provider shutdown blocks in-definitively [#3191](https://github.com/open-telemetry/opentelemetry-cpp/pull/3191) * [SEMANTIC CONVENTIONS] Upgrade to weaver 0.11.0 [#3194](https://github.com/open-telemetry/opentelemetry-cpp/pull/3194) * [DOC] Update existing maintaining dependencies doc [#3195](https://github.com/open-telemetry/opentelemetry-cpp/pull/3195) * [TEST] Change is_called_ and got_response_ to use atomic [#3204](https://github.com/open-telemetry/opentelemetry-cpp/pull/3204) * [SEMANTIC CONVENTIONS] update links to openmetrics to reference the v1.0.0 release [#3205](https://github.com/open-telemetry/opentelemetry-cpp/pull/3205) * [CI] Fix CI on ubuntu-latest [#3207](https://github.com/open-telemetry/opentelemetry-cpp/pull/3207) * [BUILD] Build break using protoc 3.14 [#3211](https://github.com/open-telemetry/opentelemetry-cpp/pull/3211) * [TEST] Build the singleton test on windows [#3183](https://github.com/open-telemetry/opentelemetry-cpp/pull/3183) * [BUILD] Add cxx feature detections [#3203](https://github.com/open-telemetry/opentelemetry-cpp/pull/3203) * [SDK] Do not frequently create and destroy http client threads [#3198](https://github.com/open-telemetry/opentelemetry-cpp/pull/3198) * [EXPORTER] Optimize OTLP HTTP compression [#3178](https://github.com/open-telemetry/opentelemetry-cpp/pull/3178) * [SDK] Fix include instrumentation scope attributes in equal method [#3214](https://github.com/open-telemetry/opentelemetry-cpp/pull/3214) * Upgrade to opentelemetry-proto 1.5.0 [#3210](https://github.com/open-telemetry/opentelemetry-cpp/pull/3210) * [TEST] Added support for SELINUX in functional tests [#3212](https://github.com/open-telemetry/opentelemetry-cpp/pull/3212) * [EDITORIAL] fix changelog entry for PR 3185 [#3217](https://github.com/open-telemetry/opentelemetry-cpp/pull/3217) * [TEST] Functional tests for OTLP/gRPC with mutual TLS [#3227](https://github.com/open-telemetry/opentelemetry-cpp/pull/3227) * [SEMCONV] Metrics are incorrectly prefixed with 'metric' [#3228](https://github.com/open-telemetry/opentelemetry-cpp/pull/3228) * [BUILD] Add OTLP/file exporter for dll and examples [#3231](https://github.com/open-telemetry/opentelemetry-cpp/pull/3231) * [Code Health] Include what you use, part 6 [#3216](https://github.com/open-telemetry/opentelemetry-cpp/pull/3216) * [CI] Spurious test failures [#3233](https://github.com/open-telemetry/opentelemetry-cpp/pull/3233) * [BUILD] Fix error ‘uint8_t’ does not name a type with gcc-15 [#3240](https://github.com/open-telemetry/opentelemetry-cpp/pull/3240) * [EXPORTER] fix throw in OtlpGrpcMetricExporter with shared grpc client [#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243) * [SDK] Better control of threads executed by opentelemetry-cpp [#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175) * [Code Health] Include what you use, part 7 [#3238](https://github.com/open-telemetry/opentelemetry-cpp/pull/3238) * [SDK] Fix lifetime of GlobalLogHandler [#3221](https://github.com/open-telemetry/opentelemetry-cpp/pull/3221) * [MAINTAINER] Add devcontainer [#3123](https://github.com/open-telemetry/opentelemetry-cpp/pull/3123) * [SDK] enable deriving from ResourceDetector to create a Resource [#3247](https://github.com/open-telemetry/opentelemetry-cpp/pull/3247) * [EXPORTER] Support handling retry-able errors for OTLP/HTTP [#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223) * [CI] Add GRPC in maintainer CI [#3248](https://github.com/open-telemetry/opentelemetry-cpp/pull/3248) * [EXPORTER] Support handling retry-able errors for OTLP/gRPC [#3219](https://github.com/open-telemetry/opentelemetry-cpp/pull/3219) * [SDK] Optimize Metric Processing for Single Collector with Delta Temporality [#3236](https://github.com/open-telemetry/opentelemetry-cpp/pull/3236) New features: * [SDK] Better control of threads executed by opentelemetry-cpp [#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175) * This feature provides a way for applications, when configuring the SDK and exporters, to participate in the execution path of internal opentelemetry-cpp threads. * The opentelemetry-cpp library provides the following: * a new ThreadInstrumentation interface, * new runtime options structures, to optionally configure the SDK: * BatchSpanProcessorRuntimeOptions * PeriodicExportingMetricReaderRuntimeOptions * BatchLogRecordProcessorRuntimeOptions * new runtime options structures, to optionally configure the OTLP HTTP exporters: * OtlpHttpExporterRuntimeOptions * OtlpHttpMetricExporterRuntimeOptions * OtlpHttpLogRecordExporterRuntimeOptions * new ThreadInstrumentation parameters, to optionally configure the CURL HttpClient * new runtime options structures, to optionally configure the OTLP FILE exporters: * OtlpFileExporterRuntimeOptions * OtlpFileMetricExporterRuntimeOptions * OtlpFileLogRecordExporterRuntimeOptions * new runtime options structure, to optionally configure the OTLP FILE client: * OtlpFileClientRuntimeOptions * Using the optional runtime options structures, an application can subclass the ThreadInstrumentation interface, and be notified of specific events of interest during the execution of an internal opentelemetry-cpp thread. * This allows an application to call, for example: * pthread_setaffinity_np(), for better performances, * setns(), to control the network namespace used by HTTP CURL connections * pthread_setname_np(), for better observability from the operating system * many more specific apis, as needed * See the documentation for ThreadInstrumentation for details. * A new example program, example_otlp_instrumented_http, shows how to use the feature, and add application logic in the thread execution code path. * Note that this feature is experimental, protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW flag in CMake. Various runtime options structures, as well as the thread instrumentation interface, may change without notice before this feature is declared stable. * [EXPORTER] Support handling retry-able errors for OTLP/HTTP [#3223](https://github.com/open-telemetry/opentelemetry-cpp/pull/3223) * This feature is experimental, protected by a WITH_OTLP_RETRY_PREVIEW flag in CMake. * [EXPORTER] Support handling retry-able errors for OTLP/gRPC [#3219](https://github.com/open-telemetry/opentelemetry-cpp/pull/3219) * This feature is experimental, protected by a WITH_OTLP_RETRY_PREVIEW flag in CMake. ## [1.18 2024-11-25] * [EXPORTER] Fix crash in ElasticsearchLogRecordExporter [#3082](https://github.com/open-telemetry/opentelemetry-cpp/pull/3082) * [BUILD] Avoid buggy warning with gcc <= 8 [#3087](https://github.com/open-telemetry/opentelemetry-cpp/pull/3087) * [API] Jaeger Propagator should not be deprecated [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) * Update bzlmod version [#3093](https://github.com/open-telemetry/opentelemetry-cpp/pull/3093) * [BUILD] Remove std::make_unique [#3098](https://github.com/open-telemetry/opentelemetry-cpp/pull/3098) * [BUILD] Fix compiling problems for gcc 4.8 [#3100](https://github.com/open-telemetry/opentelemetry-cpp/pull/3100) * [TEST] Fix linking order and gmock linking [#3106](https://github.com/open-telemetry/opentelemetry-cpp/pull/3106) * [EXPORTER] Add config options to prometheus exporter [#3104](https://github.com/open-telemetry/opentelemetry-cpp/pull/3104) * [BUILD] Add a CMake option to disable shared libs [#3095](https://github.com/open-telemetry/opentelemetry-cpp/pull/3095) * [EXPORTER] Remove out of date ETW exporter doc [#3103](https://github.com/open-telemetry/opentelemetry-cpp/pull/3103) * [EXPORTER] Add logging for async gRPC errors [#3108](https://github.com/open-telemetry/opentelemetry-cpp/pull/3108) * [BUILD] Remove aligned_storage from nostd [#3112](https://github.com/open-telemetry/opentelemetry-cpp/pull/3112) * [EXPORTER] Elastic Search exporter follow ECS guidelines [#3107](https://github.com/open-telemetry/opentelemetry-cpp/pull/3107) * [INSTALL] Resolve dependencies in opentelemetry-cpp-config.cmake [#3094](https://github.com/open-telemetry/opentelemetry-cpp/pull/3094) * [API] Add synchronous gauge [#3029](https://github.com/open-telemetry/opentelemetry-cpp/pull/3029) * [BUILD] allow building with -DWITH_OTLP_HTTP_COMPRESSION=OFF without zlib [#3120](https://github.com/open-telemetry/opentelemetry-cpp/pull/3120) * [CI] Comment the arm64 CI [#3125](https://github.com/open-telemetry/opentelemetry-cpp/pull/3125) * [API] Comply with W3C Trace Context [#3115](https://github.com/open-telemetry/opentelemetry-cpp/pull/3115) * [EXPORTER] bump prometheus to v1.3.0 [#3122](https://github.com/open-telemetry/opentelemetry-cpp/pull/3122) * [EXPORTER] Log SSL Connection Information [#3113](https://github.com/open-telemetry/opentelemetry-cpp/pull/3113) * [BUILD] Improve how to handle yield() in ARM [#3129](https://github.com/open-telemetry/opentelemetry-cpp/pull/3129) * [BUILD] Fix -Wmissing-template-arg-list-after-template-kw warning [#3133](https://github.com/open-telemetry/opentelemetry-cpp/pull/3133) * [EXPORTER]: Elasticsearch exporter put log resource in root instead of under 'resources' [#3131](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) * [TEST] Rename w3c_tracecontext_test to w3c_tracecontext_http_test_server [#3132](https://github.com/open-telemetry/opentelemetry-cpp/pull/3132) * [BUILD] Patches for building on AIX [#3127](https://github.com/open-telemetry/opentelemetry-cpp/pull/3127) * [SEMANTIC CONVENTIONS] Migration to weaver [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) * [SEMANTIC CONVENTIONS] Upgrade to semantic conventions 1.28.0 [#3139](https://github.com/open-telemetry/opentelemetry-cpp/pull/3139) * [EXPORTER] handling of invalid ports in UrlParser [#3142](https://github.com/open-telemetry/opentelemetry-cpp/pull/3142) * [CI] speed up clang-tidy workflow [#3148](https://github.com/open-telemetry/opentelemetry-cpp/pull/3148) * [EXPORTER] Allow to share gRPC clients between OTLP exporters [#3041](https://github.com/open-telemetry/opentelemetry-cpp/pull/3041) * Bump codecov/codecov-action from 4 to 5 [#3143](https://github.com/open-telemetry/opentelemetry-cpp/pull/3143) * [CI] Add cppcheck in the build [#3151](https://github.com/open-telemetry/opentelemetry-cpp/pull/3151) * [BUILD] Fix error message [#3152](https://github.com/open-telemetry/opentelemetry-cpp/pull/3152) * [EXPORTER] fix clang-tidy warnings in UrlParser [#3146](https://github.com/open-telemetry/opentelemetry-cpp/pull/3146) * [EXPORTER] Upgrade to opentelemetry-proto 1.4.0 [#3157](https://github.com/open-telemetry/opentelemetry-cpp/pull/3157) * [TEST] refactor UrlParser tests to use value-paramterized tests [#3153](https://github.com/open-telemetry/opentelemetry-cpp/pull/3153) * [TEST] add a test for ElasticSearchRecordable [#3154](https://github.com/open-telemetry/opentelemetry-cpp/pull/3154) * [BUILD] Fix missing dependency on protoc compiler [#3159](https://github.com/open-telemetry/opentelemetry-cpp/pull/3159) * [bazel] Update prometheus-cpp in MODULE.bazel [#3162](https://github.com/open-telemetry/opentelemetry-cpp/pull/3162) * [bazel] Enable --incompatible_disallow_empty_glob [#2642](https://github.com/open-telemetry/opentelemetry-cpp/pull/2642) * [INSTALL] Fix cmake/opentelemetry-cpp-config.cmake.in [#3165](https://github.com/open-telemetry/opentelemetry-cpp/pull/3165) * [BUILD] Do not set OTELCPP_PROTO_PATH in the CMake cache [#3160](https://github.com/open-telemetry/opentelemetry-cpp/pull/3160) * [BUILD] Fix build for esp32 [#3155](https://github.com/open-telemetry/opentelemetry-cpp/pull/3155) * [bazel] Update opentelemetry-proto in MODULE.bazel [#3163](https://github.com/open-telemetry/opentelemetry-cpp/pull/3163) Important changes: * [API] Jaeger Propagator should not be deprecated [#3086](https://github.com/open-telemetry/opentelemetry-cpp/pull/3086) * Deprecation of the Jaeger propagator, as announced on 2023-01-31 in version 1.8.2, is now reverted. * This deprecation turned out to be not justified, as the Jaeger propagator can be used without the (now removed) Jaeger exporter. * [EXPORTER] Change log resources location for ElasticsearchLogRecordExporter [#3119](https://github.com/open-telemetry/opentelemetry-cpp/pull/3131) * Moved from `root/resources` to `root` * [SEMANTIC CONVENTIONS] Migration to weaver [#3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) * `semantic_convention.h` header files are deprecated, replaced by `semconv/xxx_attributes.h` header files, for each `xxx` semantic attribute group. * See file DEPRECATED.md for details. Deprecations: * This release contains deprecations, see file DEPRECATED.md for details. ## [1.17 2024-10-07] * [CI] Add a clang-tidy build [#3001](https://github.com/open-telemetry/opentelemetry-cpp/pull/3001) * [BUILD] Upgrade to opentelemetry-proto 1.3.2 [#2991](https://github.com/open-telemetry/opentelemetry-cpp/pull/2991) * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) * [EXPORTER] ForceFlush before canceling the running requests on shutdown [#2727](https://github.com/open-telemetry/opentelemetry-cpp/pull/2727) * [SDK] Fix crash in PeriodicExportingMetricReader [#2983](https://github.com/open-telemetry/opentelemetry-cpp/pull/2983) * [SDK] Fix memory leak in TlsRandomNumberGenerator() constructor [#2661](https://github.com/open-telemetry/opentelemetry-cpp/pull/2661) * [EXPORTER] Ignore exception when create thread in OTLP file exporter [#3012](https://github.com/open-telemetry/opentelemetry-cpp/pull/3012) * [BUILD] Update the version in MODULE.bazel [#3015](https://github.com/open-telemetry/opentelemetry-cpp/pull/3015) * [BUILD] Fix build without vcpkg on Windows when gRPC is disabled [#3016](https://github.com/open-telemetry/opentelemetry-cpp/pull/3016) * [BUILD] Add abi_version_no bazel flag [#3020](https://github.com/open-telemetry/opentelemetry-cpp/pull/3020) * [Code health] Expand iwyu coverage to include unit tests [#3022](https://github.com/open-telemetry/opentelemetry-cpp/pull/3022) * [BUILD] Version opentelemetry_proto/proto_grpc shared libraries [#2992](https://github.com/open-telemetry/opentelemetry-cpp/pull/2992) * [SEMANTIC CONVENTIONS] Upgrade semantic conventions to 1.27.0 [#3023](https://github.com/open-telemetry/opentelemetry-cpp/pull/3023) * [SDK] Support empty histogram buckets [#3027](https://github.com/open-telemetry/opentelemetry-cpp/pull/3027) * [TEST] Fix sync problems in OTLP File exporter tests [#3031](https://github.com/open-telemetry/opentelemetry-cpp/pull/3031) * [SDK] PeriodicExportingMetricReader: future is never set, blocks until timeout [#3030](https://github.com/open-telemetry/opentelemetry-cpp/pull/3030) * [Code Health] Clang Tidy cleanup, Part 2 [#3038](https://github.com/open-telemetry/opentelemetry-cpp/pull/3038) * [Code Health] include-what-you-use cleanup, part 3 [#3004](https://github.com/open-telemetry/opentelemetry-cpp/pull/3004) * [SDK] Fix overflow in timeout logic [#3046](https://github.com/open-telemetry/opentelemetry-cpp/pull/3046) * [TEST] Add missing tests to Bazel build [#3045](https://github.com/open-telemetry/opentelemetry-cpp/pull/3045) * [TEST] update collector tests with debug exporter [#3050](https://github.com/open-telemetry/opentelemetry-cpp/pull/3050) * [EXAMPLE] update collector example with debug exporter [#3049](https://github.com/open-telemetry/opentelemetry-cpp/pull/3049) * [TEST] update references to logging exporter [#3053](https://github.com/open-telemetry/opentelemetry-cpp/pull/3053) * [EXAMPLE] Clean the tracer initialization in OStream example [#3051](https://github.com/open-telemetry/opentelemetry-cpp/pull/3051) * [EXPORTER] Fix the format of SpanLink for ETW [#3054](https://github.com/open-telemetry/opentelemetry-cpp/pull/3054) * [EXPORTER] Add in-memory metric exporter [#3043](https://github.com/open-telemetry/opentelemetry-cpp/pull/3043) * [Code Health] include-what-you-use cleanup, part 4 [#3040](https://github.com/open-telemetry/opentelemetry-cpp/pull/3040) * [BUILD] add loongarch info [#3052](https://github.com/open-telemetry/opentelemetry-cpp/pull/3052) * [CI] Update otel-collector version [#3067](https://github.com/open-telemetry/opentelemetry-cpp/pull/3067) * [SDK] Update MetricProducer interface to match spec [#3044](https://github.com/open-telemetry/opentelemetry-cpp/pull/3044) * [EXPORTER] Fix URL in ES exporter, fix ipv6 supporting for http client [#3081](https://github.com/open-telemetry/opentelemetry-cpp/pull/3081) * [EXPORTER] Add HttpHeaders in ElasticsearchLogRecordExporter [#3083](https://github.com/open-telemetry/opentelemetry-cpp/pull/3083) Breaking changes: * [REMOVAL] Remove build option `WITH_DEPRECATED_SDK_FACTORY` [#2717](https://github.com/open-telemetry/opentelemetry-cpp/pull/2717) * As announced in opentelemetry-cpp previous release 1.16.0, CMake option `WITH_DEPRECATED_SDK_FACTORY` was temporary, and to be removed by the next release. * This option is now removed. * Code configuring the SDK must be adjusted, as previously described: * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) * Before this fix: * SDK factory methods such as: * opentelemetry::sdk::trace::TracerProviderFactory::Create() * opentelemetry::sdk::metrics::MeterProviderFactory::Create() * opentelemetry::sdk::logs::LoggerProviderFactory::Create() * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() returned an API object (opentelemetry::trace::TracerProvider) to the caller. * After this fix, these methods return an SDK level object (opentelemetry::sdk::trace::TracerProvider) to the caller. * Returning an SDK object is necessary for the application to cleanup and invoke SDK level methods, such as ForceFlush(), on a provider. * The application code that configures the SDK, by calling the various provider factories, may need adjustment. * All the examples have been updated, and in particular no longer perform static_cast do convert an API object to an SDK object. Please refer to examples for guidance on how to adjust. ## [1.16.1 2024-07-17] * [BUILD] Add bazel missing BUILD file [#2720](https://github.com/open-telemetry/opentelemetry-cpp/pull/2720) * [SDK] Added reserve for spans array in BatchSpanProcessor. [#2724](https://github.com/open-telemetry/opentelemetry-cpp/pull/2724) * [DOC] Update "Using triplets" section in building-with-vcpkg documentation. [#2726](https://github.com/open-telemetry/opentelemetry-cpp/pull/2726) * [DOC] Remove comment for unused LoggerProvider initialization params [#2972](https://github.com/open-telemetry/opentelemetry-cpp/pull/2972) * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) * [TEST] Fix opentelemetry-collector bind address [#2989](https://github.com/open-telemetry/opentelemetry-cpp/pull/2989) * [EXPORTER] Fix references in AttributeValueVisitor [#2985](https://github.com/open-telemetry/opentelemetry-cpp/pull/2985) * [Code health] include-what-you-use cleanup, part 2 [#2704](https://github.com/open-telemetry/opentelemetry-cpp/pull/2704) * [Code Health] clang-tidy cleanup, part 1 [#2990](https://github.com/open-telemetry/opentelemetry-cpp/pull/2990) * [CI] Build failures with ABSEIL 20240116 and CMAKE 3.30 [#3002](https://github.com/open-telemetry/opentelemetry-cpp/pull/3002) * [CI] Enable bzlmod [#2995](https://github.com/open-telemetry/opentelemetry-cpp/pull/2995) * [Metrics SDK] Fix hash calculation for nostd::string [#2999](https://github.com/open-telemetry/opentelemetry-cpp/pull/2999) Breaking changes: * [SECURITY] Remove OTLP HTTP support for TLS 1.0 and TLS 1.1, require TLS 1.2 or better [#2722](https://github.com/open-telemetry/opentelemetry-cpp/pull/2722) * The OTLP HTTP exporter no longer accept options like: * min_TLS = 1.0 * min_TLS = 1.1 * max_TLS = 1.0 * max_TLS = 1.1 * When connecting to an OTLP HTTP endpoint, using `https`, the connection will require TLS 1.2 by default, unless min_TLS is set to 1.3 * Plain `http` connections (insecure) are not affected. ## [1.16.0] 2024-06-21 * [BUILD] Upgrade bazel abseil from 20220623.1 to 20230802.2 [#2650](https://github.com/open-telemetry/opentelemetry-cpp/pull/2650) * [BUILD] Use nostd::enable_if_t instead of std::enable_if_t [#2648](https://github.com/open-telemetry/opentelemetry-cpp/pull/2648) * [EXEMPLAR] Update ExemplarFilter and ExemplarReservoir for spec [#2372](https://github.com/open-telemetry/opentelemetry-cpp/pull/2372) * [BUILD] Link CoreFoundation on apple systems [#2655](https://github.com/open-telemetry/opentelemetry-cpp/pull/2655) * [SDK] Avoid missing conditional variable update and simplify atomic bool [#2553](https://github.com/open-telemetry/opentelemetry-cpp/pull/2553) * [BUILD] Build break in OLTP_FILE tests [#2659](https://github.com/open-telemetry/opentelemetry-cpp/pull/2659) * [EXPORTER] General cleanup for is_shutdown flags in exporters. [#2663](https://github.com/open-telemetry/opentelemetry-cpp/pull/2663) * [CI] Upgrade Maintainers CI to ubuntu-24.04 [#2670](https://github.com/open-telemetry/opentelemetry-cpp/pull/2670) * [BUILD] Upgrade to opentelemetry-proto 1.3.1 [#2669](https://github.com/open-telemetry/opentelemetry-cpp/pull/2669) * [API] Return NoopLogRecord from NoopLogger [#2668](https://github.com/open-telemetry/opentelemetry-cpp/pull/2668) * [BUILD] Remove the hard-coded separator in tracestate [#2672](https://github.com/open-telemetry/opentelemetry-cpp/pull/2672) * [SDK] Fix forceflush may wait for ever [#2584](https://github.com/open-telemetry/opentelemetry-cpp/pull/2584) * [API] DO not allow unsafe Logger::EmitLogRecord [#2673](https://github.com/open-telemetry/opentelemetry-cpp/pull/2673) * [BUILD] Read default proto version from third_party_release [#2677](https://github.com/open-telemetry/opentelemetry-cpp/pull/2677) * [CI] include-what-you-use [#2629](https://github.com/open-telemetry/opentelemetry-cpp/pull/2629) * [CI] Upgrade to clang-format 18 [#2684](https://github.com/open-telemetry/opentelemetry-cpp/pull/2684) * [CI] Fix CI failures on Ubuntu 24.04 [#2686](https://github.com/open-telemetry/opentelemetry-cpp/pull/2686) * [SEMANTIC CONVENTIONS] Upgrade to version 1.26.0 [#2687](https://github.com/open-telemetry/opentelemetry-cpp/pull/2687) * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) * [ETW] Add table name mapping for Logs other than the default Log table [#2691](https://github.com/open-telemetry/opentelemetry-cpp/pull/2691) * [CI] Remove benchmark overlay for vcpkg [#2695](https://github.com/open-telemetry/opentelemetry-cpp/pull/2695) * [BUILD] Remove the incorrect set of CMAKE_MSVC_RUNTIME_LIBRARY for vcpkg [#2696](https://github.com/open-telemetry/opentelemetry-cpp/pull/2696) * [BUILD] CMakeLists.txt: Enable CMAKE_MSVC_RUNTIME_LIBRARY support [#2652](https://github.com/open-telemetry/opentelemetry-cpp/pull/2652) * [EXPORTER] OTLP file: use thread-safe file/io [#2675](https://github.com/open-telemetry/opentelemetry-cpp/pull/2675) * [bazel] Bump version and deps [#2679](https://github.com/open-telemetry/opentelemetry-cpp/pull/2679) * [BUILD] Add support for bzlmod [#2608](https://github.com/open-telemetry/opentelemetry-cpp/pull/2608) * [BUILD] Fix Import Abseil-cpp [#2701](https://github.com/open-telemetry/opentelemetry-cpp/pull/2701) * [Code health] include-what-you-use cleanup [#2692](https://github.com/open-telemetry/opentelemetry-cpp/pull/2692) * [BUILD] Restore Bazel flag removed from public API [#2702](https://github.com/open-telemetry/opentelemetry-cpp/pull/2702) * [DOC] Fix typo tace_id -> trace_id in logger.h [#2703](https://github.com/open-telemetry/opentelemetry-cpp/pull/2703) * Bump docker/build-push-action from 5 to 6 [#2705](https://github.com/open-telemetry/opentelemetry-cpp/pull/2705) * [CI] Enable ARM64 build in CI [#2699](https://github.com/open-telemetry/opentelemetry-cpp/pull/2699) * [Code health] Remove Unicode Text from Source files [#2707](https://github.com/open-telemetry/opentelemetry-cpp/pull/2707) * [BUILD] Add option WITH_OTLP_GRPC_SSL_MTLS_PREVIEW [#2714](https://github.com/open-telemetry/opentelemetry-cpp/pull/2714) * [EXPORTER] All 2xx return codes should be considered successful. [#2712](https://github.com/open-telemetry/opentelemetry-cpp/pull/2712) Important changes: * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) * Before this fix: * The API class `opentelemetry::trace::Tracer` exposed methods such as `ForceFlush()`, `ForceFlushWithMicroseconds()`, `Close()` and `CloseWithMicroseconds()`. * These methods are meant to be used when configuring the SDK, and should not be part of the API. Exposing them was an oversight. * Two of these methods are virtual, and therefore part of the ABI. * After this fix: * In `OPENTELEMETRY_ABI_VERSION_NO 1`, nothing is changed, because removing this code would break the ABI. * In `OPENTELEMETRY_ABI_VERSION_NO 2`, these methods are moved from the API to the SDK. This is a breaking change for ABI version 2, which is still experimental. * In all cases, instrumenting an application should not invoke flush or close on a tracer, do not use these methods. Breaking changes: * [API/SDK] Provider cleanup [#2664](https://github.com/open-telemetry/opentelemetry-cpp/pull/2664) * Before this fix: * SDK factory methods such as: * opentelemetry::sdk::trace::TracerProviderFactory::Create() * opentelemetry::sdk::metrics::MeterProviderFactory::Create() * opentelemetry::sdk::logs::LoggerProviderFactory::Create() * opentelemetry::sdk::logs::EventLoggerProviderFactory::Create() returned an API object (opentelemetry::trace::TracerProvider) to the caller. * After this fix, these methods return an SDK level object (opentelemetry::sdk::trace::TracerProvider) to the caller. * Returning an SDK object is necessary for the application to cleanup and invoke SDK level methods, such as ForceFlush(), on a provider. * The application code that configures the SDK, by calling the various provider factories, may need adjustment. * All the examples have been updated, and in particular no longer perform static_cast do convert an API object to an SDK object. Please refer to examples for guidance on how to adjust. * If adjusting application code is impractical, an alternate and temporary solution is to build with option WITH_DEPRECATED_SDK_FACTORY=ON in CMake. * Option WITH_DEPRECATED_SDK_FACTORY=ON will allow to build code without application changes, posponing changes for later. * WITH_DEPRECATED_SDK_FACTORY=ON is temporary, only to provide an easier migration path. Expect this flag to be removed, as early as by the next release. Notes on experimental features: * [#2372](https://github.com/open-telemetry/opentelemetry-cpp/issues/2372) introduced `MeterProvider::SetExemplar()` which accepts en `ExemplarFilterType` enumeration with `kAlwaysOff`, `kAlwaysOn` and `kTraceBased`. ## [1.15.0] 2024-04-21 * [EXPORTER] Change OTLP HTTP content_type default to binary [#2564](https://github.com/open-telemetry/opentelemetry-cpp/pull/2564) * [DOC] Fix OTLP documentation: Default endpoint is wrong for OTLP/HTTP [#2560](https://github.com/open-telemetry/opentelemetry-cpp/pull/2560) * [BUILD] Fix old style cast warning [#2567](https://github.com/open-telemetry/opentelemetry-cpp/pull/2567) * [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter [#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530) * [BUILD] update vcpkg submodule to 2024.02.14 [#2575](https://github.com/open-telemetry/opentelemetry-cpp/pull/2575) * [SDK] Support for OTEL_SERVICE_NAME [#2577](https://github.com/open-telemetry/opentelemetry-cpp/pull/2577) * [EXPORTER] Support URL-encoded values for `OTEL_EXPORTER_OTLP_HEADERS` [#2579](https://github.com/open-telemetry/opentelemetry-cpp/pull/2579) * [BUILD] CMake cleanup for message() [#2582](https://github.com/open-telemetry/opentelemetry-cpp/pull/2582) * [BUILD] Bump CMake minimum required version to 3.9 [#2581](https://github.com/open-telemetry/opentelemetry-cpp/pull/2581) * [BUILD] Provide LIKELY / UNLIKELY macros [#2580](https://github.com/open-telemetry/opentelemetry-cpp/pull/2580) * [EXPORTER] OTLP: Fix missing ResourceMetrics SchemaURL [#2587](https://github.com/open-telemetry/opentelemetry-cpp/pull/2587) * [ETW] cleanup include path [#2594](https://github.com/open-telemetry/opentelemetry-cpp/pull/2594) * Upgrade to googletest 1.14.0 [#2596](https://github.com/open-telemetry/opentelemetry-cpp/pull/2596) * Upgrade to nlohmann_json 3.11.3 [#2595](https://github.com/open-telemetry/opentelemetry-cpp/pull/2595) * [BAZEL] Move -std=c++14 to .bazelrc [#2600](https://github.com/open-telemetry/opentelemetry-cpp/pull/2600) * [BAZEL] Fix -std=c++14 warning on Windows [#2601](https://github.com/open-telemetry/opentelemetry-cpp/pull/2601) * Upgrade to benchmark 1.8.3 [#2597](https://github.com/open-telemetry/opentelemetry-cpp/pull/2597) * Upgrade to prometheus 1.2.4 [#2598](https://github.com/open-telemetry/opentelemetry-cpp/pull/2598) * [DOC] Fix typo: Asynchronouse -> Asynchronous in meter.h [#2604](https://github.com/open-telemetry/opentelemetry-cpp/pull/2604) * [BUILD] Do not link prometheus-cpp::util when it doesn't exist [#2606](https://github.com/open-telemetry/opentelemetry-cpp/pull/2606) * [SDK] Remove unused variable [#2609](https://github.com/open-telemetry/opentelemetry-cpp/pull/2609) * [METRICS SDK] Remove extra OfferMeasurement call in SyncMetricsStorage::OfferMeasurement [#2610](https://github.com/open-telemetry/opentelemetry-cpp/pull/2610) * [MISC] Use set -e on all shell scripts and pass shellcheck --severity=error [#2616](https://github.com/open-telemetry/opentelemetry-cpp/pull/2616) * [CI] Add shellcheck --severity=error as a CI step [#2618](https://github.com/open-telemetry/opentelemetry-cpp/pull/2618) * [CI] Upgrade to abseil 20240116.1 (CMake only) [#2599](https://github.com/open-telemetry/opentelemetry-cpp/pull/2599) * [CI] Benchmark, provide units with --benchmark_min_time [#2621](https://github.com/open-telemetry/opentelemetry-cpp/pull/2621) * [EXPORTER] OTLP file exporter [#2540](https://github.com/open-telemetry/opentelemetry-cpp/pull/2540) * [CI] Use platform CMake [#2627](https://github.com/open-telemetry/opentelemetry-cpp/pull/2627) * [PROTO] Upgrade to opentelemetry-proto 1.2.0 [#2631](https://github.com/open-telemetry/opentelemetry-cpp/pull/2631) * [SDK] DefaultLogHandler to print errors to std::cerr, add LogLevel::None [#2622](https://github.com/open-telemetry/opentelemetry-cpp/pull/2622) * [SEMANTIC CONVENTIONS] Upgrade to semantic convention 1.25.0 [#2633](https://github.com/open-telemetry/opentelemetry-cpp/pull/2633) * [DOC] Add readme and examples for OTLP FILE exporters. [#2638](https://github.com/open-telemetry/opentelemetry-cpp/pull/2638) * [SEMANTIC CONVENTIONS] Rework on semantic conventions 1.25.0 [#2640](https://github.com/open-telemetry/opentelemetry-cpp/pull/2640) * [DOC] Update INSTALL.md [#2592](https://github.com/open-telemetry/opentelemetry-cpp/pull/2592) Important changes: * [EXPORTER] Gzip compression support for OTLP/HTTP and OTLP/gRPC exporter [#2530](https://github.com/open-telemetry/opentelemetry-cpp/pull/2530) * In the `OtlpHttpExporterOptions` and `OtlpGrpcExporterOptions`, a new field called compression has been introduced. This field can be set to "gzip” to enable gzip compression. * The CMake option `WITH_OTLP_HTTP_COMPRESSION` is introduced to enable gzip compression support for the OTLP HTTP Exporter and includes a dependency on zlib. * [SDK] Change OTLP HTTP content_type default to binary [#2558](https://github.com/open-telemetry/opentelemetry-cpp/pull/2558) * [CI] Use platform CMake [#2627](https://github.com/open-telemetry/opentelemetry-cpp/pull/2627) * The `CI` in github no longer install a different version of `cmake`. * It now always use the `cmake` provided by the platform. * As part of this change, the script `ci/setup_cmake.sh` was renamed to `ci/setup_googletest.sh`, for clarity, now that this script only installs googletest. * [SDK] DefaultLogHandler to print to std::cerr, add LogLevel::None [#2622](https://github.com/open-telemetry/opentelemetry-cpp/pull/2622) * Change DefaultLogHandler output * Before, the default internal logger, DefaultLogHandler, used to print to std::cout. * Now, DefaultLogHandler prints errors and warnings to std::cerr, as expected, while printing info and debug messages to std::cout. * Applications that expected to find the opentelemetry-cpp internal error log in std::cout may need adjustments, either by looking at std::cerr instead, or by using a custom log handler. * Additional LogLevel::None * LogLevel::None is a new supported log level, which does not print any message. * Custom log handlers may need to implement a new case, to avoid compiler warnings. * Numbering of log levels like OTEL_INTERNAL_LOG_LEVEL_ERROR has changed, which requires to rebuild, as the SDK ABI differs. ## [1.14.2] 2024-02-27 * [SDK] Fix observable attributes drop [#2557](https://github.com/open-telemetry/opentelemetry-cpp/pull/2557) ## [1.14.1] 2024-02-23 * [SDK] Restore Recordable API compatibility with versions < 1.14.0 [#2547](https://github.com/open-telemetry/opentelemetry-cpp/pull/2547) * [DOC] Add missing CHANGELOG. [#2549](https://github.com/open-telemetry/opentelemetry-cpp/pull/2549) * [EXPORTER] Error when grpc endpoint is empty [#2507](https://github.com/open-telemetry/opentelemetry-cpp/pull/2507) * [DOC] Fix typo in benchmarks.rst [#2542](https://github.com/open-telemetry/opentelemetry-cpp/pull/2542) Important changes: * [SDK] Restore Recordable API compatibility with versions < 1.14.0 [#2547](https://github.com/open-telemetry/opentelemetry-cpp/pull/2547) * For third party _extending_ the SDK, release 1.14.0 introduced an API breaking change compared to 1.13.0 * This fix restores API (but not ABI) compatibility of release 1.14.1 with release 1.13.0. * This allows to build a third party exporter with no source code changes, for both releases 1.14.1 and 1.13.0. ## [1.14.0] 2024-02-16 * [BUILD] Add DLL build CI pipeline with CXX20 [#2465](https://github.com/open-telemetry/opentelemetry-cpp/pull/2465) * [EXPORTER] Set `is_monotonic` flag for Observable Counters [#2478](https://github.com/open-telemetry/opentelemetry-cpp/pull/2478) * [PROTO] Upgrade to opentelemetry-proto v1.1.0 [#2488](https://github.com/open-telemetry/opentelemetry-cpp/pull/2488) * [BUILD] Introduce CXX 20 CI pipeline for MSVC/Windows [#2450](https://github.com/open-telemetry/opentelemetry-cpp/pull/2450) * [API] Propagation: fix for hex conversion to binary for odd hex strings [#2533](https://github.com/open-telemetry/opentelemetry-cpp/pull/2533) * [DOC] Fix calendar link [#2532](https://github.com/open-telemetry/opentelemetry-cpp/pull/2532) * [ETW EXPORTER] Remove namespace using in ETW exporter which affects global namespace [#2531](https://github.com/open-telemetry/opentelemetry-cpp/pull/2531) * [BUILD] Don't invoke vcpkg from this repo with CMAKE_TOOLCHAIN_FILE set [#2527](https://github.com/open-telemetry/opentelemetry-cpp/pull/2527) * [EXPORTER] Async exporting for otlp grpc [#2407](https://github.com/open-telemetry/opentelemetry-cpp/pull/2407) * [METRICS SDK] Fix attribute filtering for synchronous instruments. [#2472](https://github.com/open-telemetry/opentelemetry-cpp/pull/2472) * [BUILD] Better handling of OPENTELEMETRY_STL_VERSION under Bazel. [#2503](https://github.com/open-telemetry/opentelemetry-cpp/pull/2503) * [DOC] Fixes CI markdown error MD055 - Table pipe style [#2517](https://github.com/open-telemetry/opentelemetry-cpp/pull/2517) * [API] Propagators: do not overwrite the active span with a default invalid span [#2511](https://github.com/open-telemetry/opentelemetry-cpp/pull/2511) * [BUILD] Updated the recorded vcpkg submodule version [#2513](https://github.com/open-telemetry/opentelemetry-cpp/pull/2513) * [BUILD] Remove unnecessary usage/includes of nostd/type_traits [#2509](https://github.com/open-telemetry/opentelemetry-cpp/pull/2509) * [SEMANTIC CONVENTIONS] Upgrade to version 1.24.0 [#2461](https://github.com/open-telemetry/opentelemetry-cpp/pull/2461) * [EXAMPLES] Improve readme of Metrics example [#2510](https://github.com/open-telemetry/opentelemetry-cpp/pull/2510) * [BUILD] Clang-15 warning about `__has_trivial_destructor` [#2502](https://github.com/open-telemetry/opentelemetry-cpp/pull/2502) * [BUILD] Fix multiple assignment operators for SpinLockMutex [#2501](https://github.com/open-telemetry/opentelemetry-cpp/pull/2501) * [BUILD] Alternative way of exporting symbols (generating .def file) [#2476](https://github.com/open-telemetry/opentelemetry-cpp/pull/2476) * [CI] Make cmake.c++20*.test actually use C++20 and add cmake.c++23*.test [#2496](https://github.com/open-telemetry/opentelemetry-cpp/pull/2496) * [DOCUMENTATION] Add api reference documentation for logs [#2497](https://github.com/open-telemetry/opentelemetry-cpp/pull/2497) * [BUILD] Fix variable shadow [#2498](https://github.com/open-telemetry/opentelemetry-cpp/pull/2498) * [BUILD] Fix checks on __cplusplus under MSVC, do not assume /Zc [#2493](https://github.com/open-telemetry/opentelemetry-cpp/pull/2493) * [EXAMPLES] Use logs API instead of logs bridge API in the example [#2494](https://github.com/open-telemetry/opentelemetry-cpp/pull/2494) * [EXPORTER] Fix forward protocol encoding for ETW exporter [#2473](https://github.com/open-telemetry/opentelemetry-cpp/pull/2473) * [BUILD] Skip patch alias target [#2457](https://github.com/open-telemetry/opentelemetry-cpp/pull/2457) * [EXPORTER] Rename populate_otel_scope to without_otel_scope [#2479](https://github.com/open-telemetry/opentelemetry-cpp/pull/2479) * [EXPORTER SDK] Additional fixes after NOMINMAX removal on Windows [#2475](https://github.com/open-telemetry/opentelemetry-cpp/pull/2475) * [EXPORTER] Do not use regex in `CleanUpString` because some implementations of STL may crash. [#2464](https://github.com/open-telemetry/opentelemetry-cpp/pull/2464) * [EXPORTER] Fix Aggregation type detection in OTLP Exporter [#2467](https://github.com/open-telemetry/opentelemetry-cpp/pull/2467) * [EXPORTER] Add option to disable Prometheus otel_scope_name and otel_scope_version attributes [#2451](https://github.com/open-telemetry/opentelemetry-cpp/pull/2451) * [SEMANTIC CONVENTIONS] Code generation script fails on SELINUX [#2455](https://github.com/open-telemetry/opentelemetry-cpp/pull/2455) * [BUILD] Fix removing of NOMINMAX on Windows [#2449](https://github.com/open-telemetry/opentelemetry-cpp/pull/2449) * [BUILD] Accept path list in OPENTELEMETRY_EXTERNAL_COMPONENT_PATH [#2439](https://github.com/open-telemetry/opentelemetry-cpp/pull/2439) * [BUILD] Remove gmock from GTEST_BOTH_LIBRARIES [#2437](https://github.com/open-telemetry/opentelemetry-cpp/pull/2437) * [REMOVAL] Remove option WITH_OTLP_HTTP_SSL_PREVIEW [#2435](https://github.com/open-telemetry/opentelemetry-cpp/pull/2435) Important changes: Breaking changes: * [REMOVAL] Remove option WITH_OTLP_HTTP_SSL_PREVIEW [#2435](https://github.com/open-telemetry/opentelemetry-cpp/pull/2435) * CMake options `WITH_OTLP_HTTP_SSL_PREVIEW` and `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` are removed. Building opentelemetry-cpp without SSL support is no longer possible. * [PROTO] Upgrade to opentelemetry-proto v1.1.0 [#2488](https://github.com/open-telemetry/opentelemetry-cpp/pull/2488) * Class `opentelemetry::sdk::trace::Recordable` has a new virtual method, `SetTraceFlags()`. * This is an incompatible change for the SDK Recordable API and ABI. * Applications _configuring_ the SDK are not affected. * Third parties providing SDK _extensions_ are affected, and must provide a `SetTraceFlags()` implementation, starting with opentelemetry-cpp 1.14.0. ## [1.13.0] 2023-12-06 * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) * [SDK] Metrics ObservableRegistry Cleanup [#2376](https://github.com/open-telemetry/opentelemetry-cpp/pull/2376) * [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) * [SDK] Creating DoubleUpDownCounter with no matching view [#2379](https://github.com/open-telemetry/opentelemetry-cpp/pull/2379) * [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) * [BUILD] DLL export interface for Metrics [#2344](https://github.com/open-telemetry/opentelemetry-cpp/pull/2344) * [BUILD] enum CanonicalCode names too generic... conflict with old C defines [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) * [BUILD] Fix cpack broken package version [#2386](https://github.com/open-telemetry/opentelemetry-cpp/pull/2386) * [API] Add a new AddLink() operation to Span [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) * [opentracing-shim] Add check for sampled context [#2390](https://github.com/open-telemetry/opentelemetry-cpp/pull/2390) * [BUILD] Fix exported definitions when building DLL with STL [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) * [BUILD] Add missing includes to runtime_context_test [#2395](https://github.com/open-telemetry/opentelemetry-cpp/pull/2395) * [ADMIN] Add file .github/repository-settings.md [#2392](https://github.com/open-telemetry/opentelemetry-cpp/pull/2392) * [SDK] Fix GetLogger with empty library name [#2398](https://github.com/open-telemetry/opentelemetry-cpp/pull/2398) * [TEST] Fix compiling problem and removed -DENABLE_TEST [#2401](https://github.com/open-telemetry/opentelemetry-cpp/pull/2401) * [BUILD] Check windows options are not passed to non-Windows build [#2399](https://github.com/open-telemetry/opentelemetry-cpp/pull/2399) * [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) * [Build] Update vcpkg to latest release [#2412](https://github.com/open-telemetry/opentelemetry-cpp/pull/2412) * [SDK] Cardinality limits for metrics streams (Sync Instruments + Delta Temporality) [#2255](https://github.com/open-telemetry/opentelemetry-cpp/pull/2255) * [EXPORTER] Prometheus: Add unit to names, convert to word [#2213](https://github.com/open-telemetry/opentelemetry-cpp/pull/2213) * [Metrics] Make context optional for histogram instruments in Metrics SDK [#2416](https://github.com/open-telemetry/opentelemetry-cpp/pull/2416) * [BUILD] Fix references to trace namespace to be fully qualified [#2422](https://github.com/open-telemetry/opentelemetry-cpp/pull/2422) * [BUILD] Bump third_party/googletest to same version as bazel [#2421](https://github.com/open-telemetry/opentelemetry-cpp/pull/2421) * [BUILD] Remove defining NOMINMAX from api [#2420](https://github.com/open-telemetry/opentelemetry-cpp/pull/2420) * [BUILD] 'uint8_t' not declared in this scope with gcc 13.2.1 [#2423](https://github.com/open-telemetry/opentelemetry-cpp/pull/2423) * [BUILD] Improve the handling of OPENTELEMETRY_HAVE_WORKING_REGEX [#2430](https://github.com/open-telemetry/opentelemetry-cpp/pull/2430) * [SEMANTIC CONVENTION] Upgrade to semconv 1.23.1 [#2428](https://github.com/open-telemetry/opentelemetry-cpp/pull/2428) * [BUILD] Use fully qualified references to trace/common namespace [#2424](https://github.com/open-telemetry/opentelemetry-cpp/pull/2424) * [API] Create root span with active span [#2427](https://github.com/open-telemetry/opentelemetry-cpp/pull/2427) * [REMOVAL] Remove ZPAGES [#2433](https://github.com/open-telemetry/opentelemetry-cpp/pull/2433) Important changes: * [API] Add InstrumentationScope attributes in TracerProvider::GetTracer() [#2371](https://github.com/open-telemetry/opentelemetry-cpp/pull/2371) * TracerProvider::GetTracer() now accepts InstrumentationScope attributes. * Because this is an `ABI` breaking change, the fix is only available with the `CMake` option `WITH_ABI_VERSION_2=ON`. * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) the `ABI` is unchanged, and the fix is not available. * [API] Add a new AddLink() operation to Span [#2380](https://github.com/open-telemetry/opentelemetry-cpp/pull/2380) * New `API` Span::AddLink() adds a single link to a span. * New `API` Span::AddLinks() adds multiple links to a span. * Because this is an `ABI` breaking change, the fix is only available with the `CMake` option `WITH_ABI_VERSION_2=ON`. * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) the `ABI` is unchanged, and the fix is not available. * [BUILD] Make WITH_OTLP_HTTP_SSL_PREVIEW mainstream [#2378](https://github.com/open-telemetry/opentelemetry-cpp/pull/2378) * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_PREVIEW` is now promoted to stable. The default is changed to `ON`. * The experimental `CMake` option `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` is now promoted to stable. The default is changed to `ON`. * These build options are scheduled to be removed by the next release, building without SSL/TLS will no longer be possible. * [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) * `OtlpGrpcMetricExporterOptions` used to honor `_TRACES_` environment variables, instead of `_METRICS_` environment variables. * The implementation of `OtlpGrpcMetricExporterOptions` is now fixed. * Please check configuration variables, to make sure `_METRICS_` variables are set as expected. Breaking changes: * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead [#2370](https://github.com/open-telemetry/opentelemetry-cpp/pull/2370) * The experimental `CMake` option `WITH_REMOVE_METER_PREVIEW` is removed, use option `WITH_ABI_VERSION_2` instead. * [BUILD] enum CanonicalCode names too generic... conflict with old C defines [#2385](https://github.com/open-telemetry/opentelemetry-cpp/pull/2385) * Header file `opentelemetry/trace/canonical_code.h` is unused, and is now removed. * This header should not be included directly in an application. If this is the case, please remove any remaining include directives. * [BUILD] Fix exported definitions when building DLL with STL [#2387](https://github.com/open-telemetry/opentelemetry-cpp/pull/2387) * The MeterSelector, MeterSelectorFactory, InstrumentSelector, and InstrumentSelectorFactory APIs now use const std::string& instead of nostd::string_view for name, version and schema to maintain a single export definition for DLL. * [EXPORTER] Rework OTLP/HTTP and OTLP/GRPC exporter options [#2388](https://github.com/open-telemetry/opentelemetry-cpp/pull/2388) * `OtlpGrpcLogRecordExporter` incorrectly used `OtlpGrpcExporterOptions`, which are options for traces and not logs. * This created a bug: the `OtlpGrpcLogRecordExporter` honors `_TRACES_` environment variables, instead of `_LOGS_` environment variables. * `OtlpGrpcLogRecordExporter` is changed to use `OtlpGrpcLogRecordExporterOptions` instead, fixing the bug. * User code that initializes the SDK with a GRPC Log exporter, and uses exporter options, should adjust to replace `OtlpGrpcExporterOptions` with `OtlpGrpcLogRecordExporterOptions`. * Please check configuration variables, to make sure `_LOGS_` variables are set as expected. * [REMOVAL] Remove ZPAGES [#2433](https://github.com/open-telemetry/opentelemetry-cpp/pull/2433) * As announced in release 1.12.0, the deprecated ZPAGES exporter is now removed. ## [1.12.0] 2023-10-16 * [BUILD] Support `pkg-config` [#2269](https://github.com/open-telemetry/opentelemetry-cpp/pull/2269) * [CI] Do not automatically close stale issues [#2277](https://github.com/open-telemetry/opentelemetry-cpp/pull/2277) * [CI] Benchmark workflow fails, C++14 required to build grpc [#2278](https://github.com/open-telemetry/opentelemetry-cpp/pull/2278) * [SDK] Increase metric name maximum length from 63 to 255 characters [#2284](https://github.com/open-telemetry/opentelemetry-cpp/pull/2284) * [SEMANTIC CONVENTION] Deprecated semconv (in the spec) not deprecated (in C++) [#2285](https://github.com/open-telemetry/opentelemetry-cpp/pull/2285) * [SDK] Remove unused member variables from SyncMetricStorage [#2294](https://github.com/open-telemetry/opentelemetry-cpp/pull/2294) * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) * [API] Deliver ABI breaking changes [#2222](https://github.com/open-telemetry/opentelemetry-cpp/pull/2222) * [SDK] Allow metric instrument names to contain / characters [#2310](https://github.com/open-telemetry/opentelemetry-cpp/pull/2310) * [SDK] Fix Observable Counters/UpDownCounters [#2298](https://github.com/open-telemetry/opentelemetry-cpp/pull/2298) * [SDK] Add exemplar reservoir to async metric storage [#2319](https://github.com/open-telemetry/opentelemetry-cpp/pull/2319) * [TEST] Fix lifetime issues in prometheus test utils [#2322](https://github.com/open-telemetry/opentelemetry-cpp/pull/2322) * [EXPORTER] Prometheus: Remove explicit timestamps from metric points [#2324](https://github.com/open-telemetry/opentelemetry-cpp/pull/2324) * [EXPORTER] Prometheus: Handle attribute key collisions from sanitation [#2326](https://github.com/open-telemetry/opentelemetry-cpp/pull/2326) * [EXPORTER] Prometheus cleanup, test with TranslateToPrometheus [#2329](https://github.com/open-telemetry/opentelemetry-cpp/pull/2329) * [SDK] Fix log message in Meter::RegisterSyncMetricStorage [#2325](https://github.com/open-telemetry/opentelemetry-cpp/pull/2325) * [DOC] Simplify the project status section [#2332](https://github.com/open-telemetry/opentelemetry-cpp/pull/2332) * [EXPORTER] Prometheus: Sanitize labels according to spec [#2330](https://github.com/open-telemetry/opentelemetry-cpp/pull/2330) * [SDK] Fix deadlock when shuting down http client [#2337](https://github.com/open-telemetry/opentelemetry-cpp/pull/2337) * [Exporter] Group spans by resource and instrumentation scope in OTLP export requests [#2335](https://github.com/open-telemetry/opentelemetry-cpp/pull/2335) * [BUILD] Need fine-grained HAVE_CPP_STDLIB [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) * [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) * [REMOVAL] Drop C++11 support [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) * [EXPORTER] prometheus: add otel_scope_name and otel_scope_version labels [#2293](https://github.com/open-telemetry/opentelemetry-cpp/pull/2293) * [EXPORTER] Export resource for prometheus [#2301](https://github.com/open-telemetry/opentelemetry-cpp/pull/2301) * [BUILD] error: read-only reference ‘value’ used as ‘asm’ output [#2354](https://github.com/open-telemetry/opentelemetry-cpp/pull/2354) * [BUILD] Build break with external CMake nlohman_json package [#2353](https://github.com/open-telemetry/opentelemetry-cpp/pull/2353) * [BUILD] Upgrade libcurl to version 8.4.0 [#2358](https://github.com/open-telemetry/opentelemetry-cpp/pull/2358) * [BUILD] Fix opentracing-shim when added in super project [#2356](https://github.com/open-telemetry/opentelemetry-cpp/pull/2356) * [BUILD] Fix protoc searching with non-imported protobuf::protoc target [#2362](https://github.com/open-telemetry/opentelemetry-cpp/pull/2362) * [BUILD] Support to use different cmake package CONFIG of dependencies [#2263](https://github.com/open-telemetry/opentelemetry-cpp/pull/2263) * [SEMANTIC CONVENTION] Upgrade to semconv 1.22.0 [#2368](https://github.com/open-telemetry/opentelemetry-cpp/pull/2368) Important changes: * [API] Add InstrumentationScope attributes in MeterProvider::GetMeter() [#2224](https://github.com/open-telemetry/opentelemetry-cpp/pull/2224) * MeterProvider::GetMeter() now accepts InstrumentationScope attributes. * Because this is an `ABI` breaking change, the fix is only available with the `CMake` option `WITH_ABI_VERSION_2=ON`. * When building with `CMake` option `WITH_ABI_VERSION_1=ON` (by default) the `ABI` is unchanged, and the fix is not available. Breaking changes: * [BUILD] Need fine-grained HAVE_CPP_STDLIB [#2304](https://github.com/open-telemetry/opentelemetry-cpp/pull/2304) * In `CMAKE`, the boolean option `WITH_STL` as changed to an option that accepts the values `OFF`, `ON`, `CXX11`, `CXX14`, `CXX17`, `CXX20` and `CXX23`. * Applications makefiles that did not set WITH_STL need to use `WITH_STL=OFF` instead (this is the default). * Applications makefiles that did set WITH_STL need to use `WITH_STL=ON` instead, or may choose to pick a specific value. * In the `API` header files, the preprocessor symbol `HAVE_CPP_STDLIB` is no longer used. * Applications that did set `HAVE_CPP_STDLIB` before, need to set `OPENTELEMETRY_STL_VERSION=` instead, to build with a specific STL version (2011, 2014, 2017, 2020, 2023). * The opentelemetry-cpp makefile no longer sets CMAKE_CXX_STANDARD by itself. Instead, the CMAKE_CXX_STANDARD and/or compiler options -stdc++ used by the caller are honored. * Applications that set neither CMAKE_CXX_STANDARD nor -stdc++ options may need to provide a C++ standard in their makefiles. * [REMOVAL] Drop C++11 support [#2342](https://github.com/open-telemetry/opentelemetry-cpp/pull/2342) * Building with C++11 is no longer supported. Deprecations: * [DEPRECATION] Deprecate ZPAGES [#2291](https://github.com/open-telemetry/opentelemetry-cpp/pull/2291) ## [1.11.0] 2023-08-21 * [BUILD] Fix more cases for symbol name for 32-bit win32 DLL build [#2264](https://github.com/open-telemetry/opentelemetry-cpp/pull/2264) * [BUILD] added public link of `opentelemetry_proto_grpc` against gRPC lib (only if gRPC library is shared) [#2268](https://github.com/open-telemetry/opentelemetry-cpp/pull/2268) * [CI] use ubuntu-latest for tsan CI [#2267](https://github.com/open-telemetry/opentelemetry-cpp/pull/2267) * [SDK] Fixing an apparent logging macro bug [#2265](https://github.com/open-telemetry/opentelemetry-cpp/pull/2265) * [BUILD] Support protobuf 3.22 or upper [#2163](https://github.com/open-telemetry/opentelemetry-cpp/pull/2163) * [BUILD] Remove extra includes [#2252](https://github.com/open-telemetry/opentelemetry-cpp/pull/2252) * [LOGS API SDK] Mark logs signal as stable API/SDK [#2229](https://github.com/open-telemetry/opentelemetry-cpp/pull/2229) * [SEMANTIC CONVENTIONS] Upgrade to 1.21.0 [#2248](https://github.com/open-telemetry/opentelemetry-cpp/pull/2248) * [SDK] Valgrind errors on std::atomic variables [#2244](https://github.com/open-telemetry/opentelemetry-cpp/pull/2244) * [BUILD] Fix compile with clang 16 and libc++ [#2242](https://github.com/open-telemetry/opentelemetry-cpp/pull/2242) * [Metrics SDK] Add unit to Instrument selection criteria [#2236](https://github.com/open-telemetry/opentelemetry-cpp/pull/2236) * [SDK] Add OStreamLogRecordExporterFactory [#2240](https://github.com/open-telemetry/opentelemetry-cpp/pull/2240) * [SDK] Add support for LowMemory metrics temporality [#2234](https://github.com/open-telemetry/opentelemetry-cpp/pull/2234) * [CI] Misc build scripts cleanup [#2232](https://github.com/open-telemetry/opentelemetry-cpp/pull/2232) * [CI] Upgrade GoogleTest version from 1.12.1 to 1.13.0 [#2114](https://github.com/open-telemetry/opentelemetry-cpp/pull/2114) * [BUILD] include cstdint [#2230](https://github.com/open-telemetry/opentelemetry-cpp/pull/2230) * [EXPORTER] Support protobuf 3.22 or upper [#2163](https://github.com/open-telemetry/opentelemetry-cpp/pull/2163) * [SDK] Mark logs signal as stable API/SDK [#2229](https://github.com/open-telemetry/opentelemetry-cpp/pull/2229) Breaking changes: * [SDK] Add unit to Instrument selection criteria [#2236](https://github.com/open-telemetry/opentelemetry-cpp/pull/2236) * The `View` constructor and `ViewFactory::Create` method now takes a `unit` criteria as optional third argument. * Please adjust SDK configuration code accordingly. ## [1.10.0] 2023-07-11 * [REMOVAL] Remove the jaeger exporter [#2031](https://github.com/open-telemetry/opentelemetry-cpp/pull/2031) * [CI] Add a C++11 build [#2152](https://github.com/open-telemetry/opentelemetry-cpp/pull/2152) * [CI] Add Include what you use [#2214](https://github.com/open-telemetry/opentelemetry-cpp/pull/2214) * [CI] opentelemetry-cpp project CI [#2071](https://github.com/open-telemetry/opentelemetry-cpp/pull/2071) * [CI] Do not tag pull_request with the "need-triage" label [#2228](https://github.com/open-telemetry/opentelemetry-cpp/pull/2228) * [BUILD] Fixing CMake to build GTest on Windows [#1887](https://github.com/open-telemetry/opentelemetry-cpp/pull/1887) * [BUILD] Remove option WITH_OTLP [#2161](https://github.com/open-telemetry/opentelemetry-cpp/pull/2161) * [BUILD] Link to opentelemetry_logs even without OTLP [#2177](https://github.com/open-telemetry/opentelemetry-cpp/pull/2177) * [BUILD] Avoid dependency on protobuf from the OTLP HTTP metrics exporter header [#2179](https://github.com/open-telemetry/opentelemetry-cpp/pull/2179) * [BUILD] Add ctime header to metrics_exporter.cc [#2187](https://github.com/open-telemetry/opentelemetry-cpp/pull/2187) * [BUILD] Fix the exported symbol name for 32-bit win32 DLL [#2190](https://github.com/open-telemetry/opentelemetry-cpp/pull/2190) * [BUILD] Upgrade to opentelemetry-proto 0.20.0 [#2195](https://github.com/open-telemetry/opentelemetry-cpp/pull/2195) * [BUILD] SDK Header files cleanup, use forward declarations [#2182](https://github.com/open-telemetry/opentelemetry-cpp/pull/2182) * [BUILD] Enable building otel-cpp extensions from main repo [#1937](https://github.com/open-telemetry/opentelemetry-cpp/pull/1937) * [BUILD] Fix if check on environment variable and add CMake variable [#2207](https://github.com/open-telemetry/opentelemetry-cpp/pull/2207) * [BUILD] Add `OPENTELEMETRY_CPP_FOUND` into cmake CONFIG file [#2215](https://github.com/open-telemetry/opentelemetry-cpp/pull/2215) * [BUILD] Upgrade opentelemetry-proto to 1.0.0 [#2216](https://github.com/open-telemetry/opentelemetry-cpp/pull/2216) * [BUILD] Include nostd/string_view which is used in severity.h [#2219](https://github.com/open-telemetry/opentelemetry-cpp/pull/2219) * [TEST] Expand api singleton test to cover explicit dlopen() [#2164](https://github.com/open-telemetry/opentelemetry-cpp/pull/2164) * [API] Remove include_trace_context [#2194](https://github.com/open-telemetry/opentelemetry-cpp/pull/2194) * [API] Remove Meters [#2205](https://github.com/open-telemetry/opentelemetry-cpp/pull/2205) * [SDK] Add AdaptingCircularBufferCounter for exponential histograms [#2158](https://github.com/open-telemetry/opentelemetry-cpp/pull/2158) * [SDK] Add base2 exponential histogram indexer [#2173](https://github.com/open-telemetry/opentelemetry-cpp/pull/2173) * [SDK] Simplify SDK version [#2180](https://github.com/open-telemetry/opentelemetry-cpp/pull/2180) * [SDK] Add benchmark for base2 exponential histogram indexer [#2181](https://github.com/open-telemetry/opentelemetry-cpp/pull/2181) * [SDK] Provide builders to avoid exposing Metrics SDK internals [#2189](https://github.com/open-telemetry/opentelemetry-cpp/pull/2189) * [SDK] MeterProvider should own MeterContext, not share it [#2218](https://github.com/open-telemetry/opentelemetry-cpp/pull/2218) * [SDK] TracerProvider should own TracerContext, not share it [#2221](https://github.com/open-telemetry/opentelemetry-cpp/pull/2221) * [EXPORTER] Change OTLP Json field name to camelCase [#2162](https://github.com/open-telemetry/opentelemetry-cpp/pull/2162) * [EXPORTER] Support empty arrays in `OtlpRecordable` attributes [#2166](https://github.com/open-telemetry/opentelemetry-cpp/pull/2166) * [EXPORTER] set is_monotonic only for instrument type kCounter [#2171](https://github.com/open-telemetry/opentelemetry-cpp/pull/2171) * [EXPORTER] Fixed HTTP CURL for 32bits platforms [#2178](https://github.com/open-telemetry/opentelemetry-cpp/pull/2178) * [EXPORTER] Fix OTLP HTTP exporting in sync mode [#2193](https://github.com/open-telemetry/opentelemetry-cpp/pull/2193) * [EXPORTER] Prometheus exporter sanitizes invalid characters [#1934](https://github.com/open-telemetry/opentelemetry-cpp/pull/1934) * [EXPORTER] Prometheus: Error on ingesting samples with different value but same timestamp [#2200](https://github.com/open-telemetry/opentelemetry-cpp/pull/2200) * [EXPORTER] OTLP GRPC mTLS support [#2120](https://github.com/open-telemetry/opentelemetry-cpp/pull/2120) * [DOC] Small fix for Histogram documentation [#2156](https://github.com/open-telemetry/opentelemetry-cpp/pull/2156) * [DOC] Move Reiley Yang to emeritus [#2198](https://github.com/open-telemetry/opentelemetry-cpp/pull/2198) Important changes: * [API] Remove Meters [#2205](https://github.com/open-telemetry/opentelemetry-cpp/pull/2205) * The CMake option `WITH_REMOVE_METER_PREVIEW` was added. * This option is experimental, and may change in the future. * Enabling it is an ABI breaking change. Breaking changes: * [REMOVAL] Remove the jaeger exporter [#2031](https://github.com/open-telemetry/opentelemetry-cpp/pull/2031) * The CMake `WITH_JAEGER` option has been removed * Please remove usage of `WITH_JAEGER` from user scripts and makefiles. * [SDK] MeterProvider should own MeterContext, not share it [#2218](https://github.com/open-telemetry/opentelemetry-cpp/pull/2218) * The `MeterProvider` constructor now takes a `unique_ptr` on `MeterContext`, instead of a `shared_ptr`. * Please adjust SDK configuration code accordingly. * [SDK] TracerProvider should own TracerContext, not share it [#2221](https://github.com/open-telemetry/opentelemetry-cpp/pull/2221) * The `TracerProvider` constructor now takes a `unique_ptr` on `TracerContext`, instead of a `shared_ptr`. * The `LoggerProvider` constructor now takes a `unique_ptr` on `LoggerContext`, instead of a `shared_ptr`. * Please adjust SDK configuration code accordingly. ## [1.9.1] 2023-05-26 * [DEPRECATION] Drop C++11 support [#2146](https://github.com/open-telemetry/opentelemetry-cpp/pull/2146) * [CI] Upgrade Bazel and Bazelisk version [#2118](https://github.com/open-telemetry/opentelemetry-cpp/pull/2118) * [CI] Upgrade Google Benchmark version from 1.6.0 to 1.7.1 [#2116](https://github.com/open-telemetry/opentelemetry-cpp/pull/2116) * [CI] Upgrade Nlohmann JSON library version from 3.10.5 to 3.11.2 [#2115](https://github.com/open-telemetry/opentelemetry-cpp/pull/2115) * [BUILD] Missed include [#2143](https://github.com/open-telemetry/opentelemetry-cpp/pull/2143) * [BUILD] Add opentelemetry_proto_grpc and allow build shared opentelemetry_proto and opentelemetry_proto_grpc on non-Windows platform. [#2097](https://github.com/open-telemetry/opentelemetry-cpp/pull/2097) * [BUILD] Warning cleanup, single character wrapped by std::string [#2137](https://github.com/open-telemetry/opentelemetry-cpp/pull/2137) * [BUILD] Add missing target dependencies [#2128](https://github.com/open-telemetry/opentelemetry-cpp/pull/2128) * [BUILD] Fix if JSON library already added another CMake target [#2126](https://github.com/open-telemetry/opentelemetry-cpp/pull/2126) * [BUILD] shared libraries with version suffix, along with the symbolic link [#2109](https://github.com/open-telemetry/opentelemetry-cpp/pull/2109) * [BUILD] Show warning message if WITH_OTLP is enabled [#2112](https://github.com/open-telemetry/opentelemetry-cpp/pull/2112) * [BUILD] Add missing STL header. [#2107](https://github.com/open-telemetry/opentelemetry-cpp/pull/2107) * [BUILD] Build break with old curl, macro CURL_VERSION_BITS unknown [#2102](https://github.com/open-telemetry/opentelemetry-cpp/pull/2102) * [BUILD] Transitive dependency issue with the otlp http exporter [#2154](https://github.com/open-telemetry/opentelemetry-cpp/pull/2154) * [TEST] Add unit test for log body implicit conversions. [#2136](https://github.com/open-telemetry/opentelemetry-cpp/pull/2136) * [TEST] Add event id to logger benchmark method [#2133](https://github.com/open-telemetry/opentelemetry-cpp/pull/2133) * [API] Fix inclusion header files and use forward declaration [#2124](https://github.com/open-telemetry/opentelemetry-cpp/pull/2124) * [API] Add user facing Logging API and Benchmarks [#2094](https://github.com/open-telemetry/opentelemetry-cpp/pull/2094) * [SDK] SDK support for the new OTel log [#2123](https://github.com/open-telemetry/opentelemetry-cpp/pull/2123) * [EXPORTER] Fixed HTTP session cleanup on shutdown [#2111](https://github.com/open-telemetry/opentelemetry-cpp/pull/2111) * [EXPORTER] Delegate all API calls of gRPC into opentelemetry_exporter_otlp_grpc_client, and make it contains all symbols needed. [#2005](https://github.com/open-telemetry/opentelemetry-cpp/pull/2005) * [DOC] Add Marc as maintainer. [#2027](https://github.com/open-telemetry/opentelemetry-cpp/pull/2027) Breaking changes: * Add opentelemetry_proto_grpc and move gRPC sources into it. [#2097](https://github.com/open-telemetry/opentelemetry-cpp/pull/2097) * There will be no breaking changes for users who only use OTLP exporters and do not directly use opentelemetry-cpp::proto. However, it is important to note that `opentelemetry-cpp::proto` no longer contains generated gRPC codes , and all components that depend on these gRPC codes should also link to `opentelemetry-cpp::proto_grpc`. Deprecations: * The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. * C++11 support is to end, C++14 will be supported instead, see [DEPRECATED](./DEPRECATED.md) for details. ## [1.9.0] 2023-04-12 * [CI] Make build environment parallel (Windows) [#2080](https://github.com/open-telemetry/opentelemetry-cpp/pull/2080) * [CI] Make build environment parallel (Linux) [#2076](https://github.com/open-telemetry/opentelemetry-cpp/pull/2076) * [CI] Remove separate run of metrics ostream example [#2030](https://github.com/open-telemetry/opentelemetry-cpp/pull/2030) * [BUILD] Include directory path added for Zipkin exporter example [#2069](https://github.com/open-telemetry/opentelemetry-cpp/pull/2069) * [BUILD] Ignore more warning in generated protobuf files [#2067](https://github.com/open-telemetry/opentelemetry-cpp/pull/2067) * [BUILD] Clean warnings in ETW exporters [#2063](https://github.com/open-telemetry/opentelemetry-cpp/pull/2063) * [BUILD] Fix default value of OPENTELEMETRY_INSTALL_default [#2062](https://github.com/open-telemetry/opentelemetry-cpp/pull/2062) * [SEMANTIC CONVENTIONS] Upgrade to version 1.20.0 [#2088](https://github.com/open-telemetry/opentelemetry-cpp/pull/2088) * [SEMANTIC CONVENTIONS] Upgrade to version 1.19.0 [#2017](https://github.com/open-telemetry/opentelemetry-cpp/pull/2017) * [API] Checking indices before dereference in string utils [#2040](https://github.com/open-telemetry/opentelemetry-cpp/pull/2040) * [API] Export factory class of log provider [#2041](https://github.com/open-telemetry/opentelemetry-cpp/pull/2041) * [SDK] Implement Forceflush for Periodic Metric Reader [#2064](https://github.com/open-telemetry/opentelemetry-cpp/pull/2064) * [SDK] Add `ForceFlush` for all `LogRecordExporter` and `SpanExporter` [#2000](https://github.com/open-telemetry/opentelemetry-cpp/pull/2000) * [SDK] Fix schema URL precedence bug in `Resource::Merge` [#2036](https://github.com/open-telemetry/opentelemetry-cpp/pull/2036) * [SDK] Use sdk_start_ts for MetricData start_ts for instruments having cumulative aggregation temporality. [#2086](https://github.com/open-telemetry/opentelemetry-cpp/pull/2086) * [EXPORTER] Add OTLP HTTP SSL support [#1793](https://github.com/open-telemetry/opentelemetry-cpp/pull/1793) * [EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE [#2060](https://github.com/open-telemetry/opentelemetry-cpp/pull/2060) * [EXAMPLES] Remove unused 'alerting' section from prometheus.yml in examples [#2055](https://github.com/open-telemetry/opentelemetry-cpp/pull/2055) * [EXAMPLES] Fix view names in Prometheus example [#2034](https://github.com/open-telemetry/opentelemetry-cpp/pull/2034) * [DOC] Fix some docs typo [#2057](https://github.com/open-telemetry/opentelemetry-cpp/pull/2057) * [DOC] Update OpenTracing shim README.md [#2028](https://github.com/open-telemetry/opentelemetry-cpp/pull/2028) * [DOC] INSTALL doc clarifications [#2078](https://github.com/open-telemetry/opentelemetry-cpp/pull/2078) Important changes: * [EXPORTER] GRPC endpoint scheme should take precedence over OTEL_EXPORTER_OTLP_TRACES_INSECURE [#2060](https://github.com/open-telemetry/opentelemetry-cpp/pull/2060) * The logic to decide whether or not an OTLP GRPC exporter uses SSL has changed to comply with the specification: * Before this change, the following settings were evaluated, in order: * OTEL_EXPORTER_OTLP_TRACES_INSECURE (starting with 1.8.3) * OTEL_EXPORTER_OTLP_INSECURE (starting with 1.8.3) * OTEL_EXPORTER_OTLP_TRACES_SSL_ENABLE * OTEL_EXPORTER_OTLP_SSL_ENABLE * With this change, the following settings are evaluated, in order: * The GRPC endpoint scheme, if provided: * "https" imply with SSL, * "http" imply without ssl. * OTEL_EXPORTER_OTLP_TRACES_INSECURE * OTEL_EXPORTER_OTLP_INSECURE * OTEL_EXPORTER_OTLP_TRACES_SSL_ENABLE * OTEL_EXPORTER_OTLP_SSL_ENABLE * As a result, a behavior change for GRPC SSL is possible, because the endpoint scheme now takes precedence. Please verify configuration settings for the GRPC endpoint. * [SDK] Add `ForceFlush` for all `LogRecordExporter` and `SpanExporter` [#2000](https://github.com/open-telemetry/opentelemetry-cpp/pull/2000) * `LogRecordExporter` and `SpanExporter` add a new virtual function `ForceFlush`, and if users implement any customized `LogRecordExporter` and `SpanExporter`, they should also implement this function. There should be no impact if users only use factory to create exporters. Deprecations: * The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. ## [1.8.3] 2023-03-06 * Provide version major/minor/patch macros [#2014](https://github.com/open-telemetry/opentelemetry-cpp/pull/2014) * [BUILD] Add `OPENTELEMETRY_INSTALL` to allow user to skip install targets. [#2022](https://github.com/open-telemetry/opentelemetry-cpp/pull/2022) * [SDK] Rename the global SDK version variables to avoid naming clash [#2011](https://github.com/open-telemetry/opentelemetry-cpp/pull/2011) * [BUILD] Fix typo in CMakeLists.txt [#2010](https://github.com/open-telemetry/opentelemetry-cpp/pull/2010) * [EXPORTER] fix Prometheus test iterator iterator increment [#2006](https://github.com/open-telemetry/opentelemetry-cpp/pull/2006) * [SDK]Add attributes for InstrumentationScope [#2004](https://github.com/open-telemetry/opentelemetry-cpp/pull/2004) * [METRICS SDK] Performance improvement in measurement processing [#1993](https://github.com/open-telemetry/opentelemetry-cpp/pull/1993) * [EXAMPLE] Add example for logs ostream exporter [#1992](https://github.com/open-telemetry/opentelemetry-cpp/pull/1992) * [ETW Exporter] Support serialize span/log attributes into JSON [#1991](https://github.com/open-telemetry/opentelemetry-cpp/pull/1991) * [ETW Exporter]Do not overwrite ParentId when setting attribute on Span [#1989](https://github.com/open-telemetry/opentelemetry-cpp/pull/1989) * Upgrade prometheus-cpp to v1.1.0 [#1954](https://github.com/open-telemetry/opentelemetry-cpp/pull/1954) * Convert Prometheus Exporter to Pull MetricReader [#1953](https://github.com/open-telemetry/opentelemetry-cpp/pull/1953) * [DOCS] Add alpine packages to INSTALL.md [#1957](https://github.com/open-telemetry/opentelemetry-cpp/pull/1957) * [METRICS SDK] Add benchmark tests for Sum Aggregation. [#1948](https://github.com/open-telemetry/opentelemetry-cpp/pull/1948) * [BUILD] Build OpenTelemetry SDK and exporters into DLL [#1932](https://github.com/open-telemetry/opentelemetry-cpp/pull/1932) * [CI] Enforce copyright check in CI [#1965](https://github.com/open-telemetry/opentelemetry-cpp/pull/1965) * [BUILD] Fix typo GENENV -> GETENV [#1972](https://github.com/open-telemetry/opentelemetry-cpp/pull/1972) * [SEMANTIC CONVENTIONS] Upgrade to version 1.18.0 [#1974](https://github.com/open-telemetry/opentelemetry-cpp/pull/1974) * [EXT] Fix thread-safety when shutdown. [#1977](https://github.com/open-telemetry/opentelemetry-cpp/pull/1977) * [SDK] Fix missing ObservedTimestamp. [#1985](https://github.com/open-telemetry/opentelemetry-cpp/pull/1985) * [METRICS SDK] fix variable names [#1987](https://github.com/open-telemetry/opentelemetry-cpp/pull/1987) * [EXPORTER] Fix Prometheus server crash on listening to already used port [#1986](https://github.com/open-telemetry/opentelemetry-cpp/pull/1986) * [EXPORTER] Boolean environment variables not parsed per the spec [#1982](https://github.com/open-telemetry/opentelemetry-cpp/pull/1982) * [EXPORTER] Opentracing shim [#1909](https://github.com/open-telemetry/opentelemetry-cpp/pull/1909) ## [1.8.2] 2023-01-31 * Remove redundant macro check in nostd::shared_ptr [#1939](https://github.com/open-telemetry/opentelemetry-cpp/pull/1939) * Fix typo in packages.cmake causing incorrect nuget package versions [#1936](https://github.com/open-telemetry/opentelemetry-cpp/pull/1936) * [METRICS] Custom Aggregation support [#1899](https://github.com/open-telemetry/opentelemetry-cpp/pull/1899) * Small fix in INSTALL.md for enabling building package. [#1930](https://github.com/open-telemetry/opentelemetry-cpp/pull/1930) * [METRICS] Fix warning for misconfiguration of PeriodicExportingMetricReader [#1929](https://github.com/open-telemetry/opentelemetry-cpp/pull/1929) * Make macros.h available for all source files via version.h [#1918](https://github.com/open-telemetry/opentelemetry-cpp/pull/1918) * [METRICS] Histogram Aggregation: Fix bucket detection logic, performance improvements, and benchmark tests [#1869](https://github.com/open-telemetry/opentelemetry-cpp/pull/1869) * Remove unused namespace alias for nostd [#1914](https://github.com/open-telemetry/opentelemetry-cpp/pull/1914) * [METRICS] Update meter.h [#1907](https://github.com/open-telemetry/opentelemetry-cpp/pull/1907) * sdk::resource::Resource::Merge should be const [#1905](https://github.com/open-telemetry/opentelemetry-cpp/pull/1905) * [METRICS] Collect and Export metric data before PeriodicMetricReader shutdown. [#1860](https://github.com/open-telemetry/opentelemetry-cpp/pull/1860) * [ETW EXPORTER] Add Virtual destructor for TailSampler, Update Maintainer mode warnings for MSVC [#1897](https://github.com/open-telemetry/opentelemetry-cpp/pull/1897) * Fix #1867 Orderly shutdown in examples [#1868](https://github.com/open-telemetry/opentelemetry-cpp/pull/1868) * [METRICS] minor metrics handling optimizations [#1890](https://github.com/open-telemetry/opentelemetry-cpp/pull/1890) * fix SpinLockMutex for Intel Compiler [#1885](https://github.com/open-telemetry/opentelemetry-cpp/pull/1885) * [LOGS] Change BatchLogRecordProcessorFactory::Create to static method [#1876](https://github.com/open-telemetry/opentelemetry-cpp/pull/1876) * Enable generating deb, rpm, NuGet, tgz, zip package through cmake build [#1662](https://github.com/open-telemetry/opentelemetry-cpp/pull/1662) * Updated clone command in INSTALL.md [#1818](https://github.com/open-telemetry/opentelemetry-cpp/pull/1818) * Small cleanup to remove old metrics design docs [#1855](https://github.com/open-telemetry/opentelemetry-cpp/pull/1855) * [BUILD] Fix build error with older version of VS2017 compiler. [1857](https://github.com/open-telemetry/opentelemetry-cpp/pull/1857) * [EXPORTERS] Enable setting Span endtime for ETW exporter [#1846](https://github.com/open-telemetry/opentelemetry-cpp/pull/1846) * [REMOVAL] Remove deprecated experimental semantic conventions [#1743](https://github.com/open-telemetry/opentelemetry-cpp/pull/1743) * [EXPORTERS] Fix console debug logs for otlp exporters. [#1848](https://github.com/open-telemetry/opentelemetry-cpp/pull/1848) * [LOGS] Add `include_trace_context` and `EventLogger` [#1884](https://github.com/open-telemetry/opentelemetry-cpp/pull/1884) * [METRICS] Change BatchLogRecordProcessorFactory::Create to static method * [BUILD] Fix OTELCPP_MAINTAINER_MODE [#1844](https://github.com/open-telemetry/opentelemetry-cpp/pull/1844) * [BUILD] Fix compatibility when using clang and libc++, upgrade GTest and cmake when using C++20 [#1852](https://github.com/open-telemetry/opentelemetry-cpp/pull/1852) * [SEMANTIC CONVENTIONS] Upgrade to version 1.16.0 [#1854](https://github.com/open-telemetry/opentelemetry-cpp/pull/1854) * [SDK] BatchSpanProcessor now logs a warning when dropping a span because the queue is full [1871](https://github.com/open-telemetry/opentelemetry-cpp/pull/1871) * [BUILD] Migrate from @bazel_tools//platforms to [Bazel Platforms](https://github.com/bazelbuild/platforms) to enable Bazel 6.0.0 compatibility [#1873](https://github.com/open-telemetry/opentelemetry-cpp/pull/1873) * [BUILD] Cleanup CMake makefiles for nlohmann_json [#1912](https://github.com/open-telemetry/opentelemetry-cpp/pull/1912) * [BUILD] Cleanup CMake makefiles for CURL usage [#1916](https://github.com/open-telemetry/opentelemetry-cpp/pull/1916) * [SEMANTIC CONVENTIONS] Upgrade to version 1.17.0 [#1927](https://github.com/open-telemetry/opentelemetry-cpp/pull/1927) * [MAINTAINER DOC] Define and document a deprecation process, [DEPRECATION] Deprecate the Jaeger exporter, implemented by [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) * [BUILD] OTLP HTTP Exporter has build warnings in maintainer mode [#1943](https://github.com/open-telemetry/opentelemetry-cpp/pull/1943) Deprecations: * [MAINTAINER DOC] Define and document a deprecation process, [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) * A new file, [DEPRECATED](./DEPRECATED.md) list all the code currently deprecated. * A new [deprecation process](./docs/deprecation-process.md) details the plan to deprecate and later remove code. * [DEPRECATION] Deprecate the Jaeger exporter [#1923](https://github.com/open-telemetry/opentelemetry-cpp/pull/1923) * The Jaeger Exporter is deprecated, see [DEPRECATED](./DEPRECATED.md) for details. Important changes: * [BUILD] Cleanup CMake makefiles for CURL usage [#1916](https://github.com/open-telemetry/opentelemetry-cpp/pull/1916) * CMake option `WITH_OTLP_HTTP` * Before this change, the CMake option `WITH_OTLP_HTTP` was unpredictable, sometime set to ON and sometime set to OFF by default, depending on whether a CURL package was found or not. The option `WITH_OTLP_HTTP` was sometime not displayed in the ccmake UI, making it impossible to even discover there is an option of that name. * With this change, CMake option `WITH_OTLP_HTTP` is always OFF by default. WITH_OTLP_HTTP MUST be set to ON explicitly to build the OTLP HTTP exporter. The option is always visible in the ccmake UI. * CMake option `BUILD_W3CTRACECONTEXT_TEST` * Before this change, the W3C trace context tests were built, or not, in an unpredictable way, depending on the presence, or not, of a CURL package. In particular, the build could ignore the W3C trace context tests even when BUILD_W3CTRACECONTEXT_TEST=ON. * With this change, option BUILD_W3CTRACECONTEXT_TEST is honored. * HTTP client/server examples * Before this change, the HTTP client/server examples were built, or not, in an unpredictable way, depending on the presence, or not, of a CURL package. * With this change, a new option `WITH_EXAMPLES_HTTP` is used to build the HTTP client/server examples. ## [1.8.1] 2022-12-04 * [ETW Exporter] Tail based sampling support [#1780](https://github.com/open-telemetry/opentelemetry-cpp/pull/1780) * [EXPORTERS] fix typo [affecting otlp exported histogram metrics max uint] [#1827](https://github.com/open-telemetry/opentelemetry-cpp/pull/1827) * [EXPORTERS] fix enum-compare-switch warning [#1833](https://github.com/open-telemetry/opentelemetry-cpp/pull/1833) * [METRICS] Change default temporality as "Cumulative" for OTLP metrics exporters [#1828](https://github.com/open-telemetry/opentelemetry-cpp/pull/1828) * [BUILD] Moved otlp_grpc_utils.cc to opentelemetry_exporter_otlp_grpc_client. [#1829](https://github.com/open-telemetry/opentelemetry-cpp/pull/1829) * Fix type mismatch when move nostd::shared_ptr [#1815](https://github.com/open-telemetry/opentelemetry-cpp/pull/1815) * [BUILD] Fix Prometheus target name [#1820](https://github.com/open-telemetry/opentelemetry-cpp/pull/1820) * Clean unused docker files [#1817](https://github.com/open-telemetry/opentelemetry-cpp/pull/1817) * [BUILD] Fix default bazel build [#1816](https://github.com/open-telemetry/opentelemetry-cpp/pull/1816) * [BUILD] move client::nosend under test_common [#1811](https://github.com/open-telemetry/opentelemetry-cpp/pull/1811) * [BUILD] Fix opentelemetry-proto file exists check [#1824](https://github.com/open-telemetry/opentelemetry-cpp/pull/1824) ## [1.8.0] 2022-11-27 * [DOC] Update Metrics status in README.md [#1722](https://github.com/open-telemetry/opentelemetry-cpp/pull/1722) * [DOC] Remove misleading comments about ABI compatibility for nostd::span [#1731](https://github.com/open-telemetry/opentelemetry-cpp/pull/1731) * [BUILD] Bump abseil-cpp for cmake CI [#1807](https://github.com/open-telemetry/opentelemetry-cpp/pull/1807) * [Exporter] Add status code to OTLP grpc trace log [#1792](https://github.com/open-telemetry/opentelemetry-cpp/pull/1792) * [Exporter] add fix for prometheus exporter build [#1795](https://github.com/open-telemetry/opentelemetry-cpp/pull/1795) * [BUILD] Add option WITH_BENCHMARK to disable building benchmarks [#1794](https://github.com/open-telemetry/opentelemetry-cpp/pull/1794) * [BUILD] Fix CI benchmark [#1799](https://github.com/open-telemetry/opentelemetry-cpp/pull/1799) * [BUILD] bump to gRPC v1.48.1 for bazel CIs [#1786](https://github.com/open-telemetry/opentelemetry-cpp/pull/1786) * [BUILD] Fix CI build [#1798](https://github.com/open-telemetry/opentelemetry-cpp/pull/1798) * [BUILD] Fix clang-format in CI [#1796](https://github.com/open-telemetry/opentelemetry-cpp/pull/1796) * Fix session lock of OtlpHttpClient [#1760](https://github.com/open-telemetry/opentelemetry-cpp/pull/1760) * [Metrics SDK] Add MeterContext::ForEachMeter() method to process callbacks on Meter in thread-safe manner [#1783](https://github.com/open-telemetry/opentelemetry-cpp/pull/1783) * [DOC] Document that clang-format version 10.0 is used. [#1782](https://github.com/open-telemetry/opentelemetry-cpp/pull/1782) * [BUILD] Upgrade bazel build to use abseil-cpp-20220623.1 [#1779](https://github.com/open-telemetry/opentelemetry-cpp/pull/1779) * Fix GlobalLogHandler singleton creation order [#1767](https://github.com/open-telemetry/opentelemetry-cpp/pull/1767) * [Metrics SDK] Change Prometheus CMake target name [#1765](https://github.com/open-telemetry/opentelemetry-cpp/pull/1765) * [DOC] Cleanup INSTALL.md [#1757](https://github.com/open-telemetry/opentelemetry-cpp/pull/1757) * [DOC] Format config options in OTLP exporter readme [#1748](https://github.com/open-telemetry/opentelemetry-cpp/pull/1748) * [DOC] Cleanup ENABLE_METRICS_PREVIEW [#1745](https://github.com/open-telemetry/opentelemetry-cpp/pull/1745) * [Build] Multiple CURL packages leads to invalid build (#1738) [#1739](https://github.com/open-telemetry/opentelemetry-cpp/pull/1739) * [Metrics SDK] Cleanup ENABLE_METRICS_PREVIEW [#1735](https://github.com/open-telemetry/opentelemetry-cpp/pull/1735) * [Logs SDK] LogProcessor, LogExporter class name [#1736](https://github.com/open-telemetry/opentelemetry-cpp/pull/1736) * [Metrics SDK] Cleanup of old _metric api/sdk [#1734](https://github.com/open-telemetry/opentelemetry-cpp/pull/1734) * [ETW Exporter] Fix span timestamp(s) precision to nanoseconds [#1726](https://github.com/open-telemetry/opentelemetry-cpp/pull/1726) * [LOGS SDK] Rename LogProcessor and LogExporter to LogRecordProcessor and LogRecordExporter [#1727](https://github.com/open-telemetry/opentelemetry-cpp/pull/1727) * [METRICS SDK] - Remove old metrics from Github CI [#1733](https://github.com/open-telemetry/opentelemetry-cpp/pull/1733) * [BUILD] Add CMake OTELCPP_PROTO_PATH [#1730](https://github.com/open-telemetry/opentelemetry-cpp/pull/1730) * [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0 [#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761) * [LOGS SDK] New LogRecord and logs::Recordable implementations. [#1766](https://github.com/open-telemetry/opentelemetry-cpp/pull/1766) Deprecation notes: * [Deprecation] Deprecate experimental semantic conventions [#1744](https://github.com/open-telemetry/opentelemetry-cpp/pull/1744) * The file `api/include/opentelemetry/trace/experimental_semantic_conventions.h` is deprecated, and will be removed in a future release. Use file `api/include/opentelemetry/trace/semantic_conventions.h` instead. * The file `sdk/include/opentelemetry/sdk/resource/experimental_semantic_conventions.h` is deprecated, and will be removed in a future release. Use file `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` instead. * The function, declared in the global namespace `uint32_t hashCode(const char *str, uint32_t h = 0)` is deprecated, and will be removed in a future release. No replacement will be provided. Note that function `opentelemetry::utils::hashCode`, declared in the ETW exporter, is not affected by this deprecation. Breaking changes: * [SEMANTIC CONVENTIONS] Upgrade to version 1.15.0 [#1761](https://github.com/open-telemetry/opentelemetry-cpp/pull/1761) * Naming of semantic conventions has changed from uppercase constants, like `SemanticConventions::SERVICE_NAME`, to camel case, like `SemanticConventions::kServiceName`. This is necessary to avoid collisions with macros in general, which breaks the build on some platforms. * Semantic conventions are flagged as experimental, which is why this change is done in this release. ## [1.7.0] 2022-10-28 * [METRICS SDK] Validate Instrument meta data (name, unit, description) [#1713](https://github.com/open-telemetry/opentelemetry-cpp/pull/1713) * [DOCS] Document libthrift 0.12.0 doesn't work with Jaeger exporter [#1714](https://github.com/open-telemetry/opentelemetry-cpp/pull/1714) * [Metrics SDK] Add Monotonic Property to Sum Aggregation, and unit tests for Up Down Counter [#1675](https://github.com/open-telemetry/opentelemetry-cpp/pull/1675) * [Metrics SDK] Move Metrics Exemplar processing behind feature flag [#1710](https://github.com/open-telemetry/opentelemetry-cpp/pull/1710) * [Metrics API/SDK] Change Meter API/SDK to return nostd::unique_ptr for Sync Instruments [#1707](https://github.com/open-telemetry/opentelemetry-cpp/pull/1707) which includes breaking change in the Metrics api and sdk. * [BUILD] Add e2e test to asan & tsan CI [#1670](https://github.com/open-telemetry/opentelemetry-cpp/pull/1670) * [BUILD] Add otlp-grpc example bazel [#1708](https://github.com/open-telemetry/opentelemetry-cpp/pull/1708) * [TRACE SDK] Fix debug log of OTLP HTTP exporter and ES log exporter [#1703](https://github.com/open-telemetry/opentelemetry-cpp/pull/1703) * [METRICS SDK] Fix a potential precision loss on integer in ReservoirCellIndexFor [#1696](https://github.com/open-telemetry/opentelemetry-cpp/pull/1696) * [METRICS SDK] Fix Histogram crash [#1685](https://github.com/open-telemetry/opentelemetry-cpp/pull/1685) * [METRICS SDK] Fix:1676 Segfault when short export period is used for metrics [#1682](https://github.com/open-telemetry/opentelemetry-cpp/pull/1682) * [METRICS SDK] Add timeout support to MeterContext::ForceFlush [#1673](https://github.com/open-telemetry/opentelemetry-cpp/pull/1673) * [DOCS] - Minor updates to OStream Metrics exporter documentation [#1679](https://github.com/open-telemetry/opentelemetry-cpp/pull/1679) * [DOCS] Fix:#1575 API Documentation for Metrics SDK and API [#1678](https://github.com/open-telemetry/opentelemetry-cpp/pull/1678) * [BUILD] Fixed compiler warnings [#1677](https://github.com/open-telemetry/opentelemetry-cpp/pull/1677) * [METRICS SDK] Fix threading issue between Meter::RegisterSyncMetricStorage and Meter::Collect [#1666](https://github.com/open-telemetry/opentelemetry-cpp/pull/1666) * [METRICS SDK] Fix data race on MeterContext::meters_ [#1668](https://github.com/open-telemetry/opentelemetry-cpp/pull/1668) * [METRICS SDK] Fix observable Gauge metrics generation [#1651](https://github.com/open-telemetry/opentelemetry-cpp/pull/1651) * [BUILD] Detect ARCH=sparc in CMake [#1660](https://github.com/open-telemetry/opentelemetry-cpp/pull/1660) * [SDK] Add user agent for OTLP http/grpc client [#1657](https://github.com/open-telemetry/opentelemetry-cpp/pull/1657) * [BUILD] Fix clang and gcc warnings [#1658](https://github.com/open-telemetry/opentelemetry-cpp/pull/1658) * [Metrics SDK] Add Metrics ExemplarFilter and ExemplarReservoir [#1584](https://github.com/open-telemetry/opentelemetry-cpp/pull/1584) * [LOGS SDK] Rename OnReceive to OnEmit [#1652](https://github.com/open-telemetry/opentelemetry-cpp/pull/1652) * [METRICS SDK] Fix Observable Gauge does not reflect updated values, and send the old value always [#1641](https://github.com/open-telemetry/opentelemetry-cpp/pull/1641) * [Metrics SDK] Change boundary type to double for Explicit Bucket Histogram Aggregation, and change default bucket range [#1626](https://github.com/open-telemetry/opentelemetry-cpp/pull/1626) * [METRICS SDK] Fix occasional Segfault with LongCounter instrument [#1638](https://github.com/open-telemetry/opentelemetry-cpp/pull/1638) * [BUILD] Bump vcpk to 2022.08.15 [#1633](https://github.com/open-telemetry/opentelemetry-cpp/pull/1633) * [BUILD] Bump gRPC to v1.48.1 for CMake Linux CI [#1608](https://github.com/open-telemetry/opentelemetry-cpp/pull/1608) * [Metrics] Switch to explicit 64 bit integers [#1686](https://github.com/open-telemetry/opentelemetry-cpp/pull/1686) which includes breaking change in the Metrics api and sdk. * [Metrics SDK] Add support for Pull Metric Exporter [#1701](https://github.com/open-telemetry/opentelemetry-cpp/pull/1701) which includes breaking change in the Metrics api. * [BUILD] Add CMake OTELCPP_MAINTAINER_MODE [#1650](https://github.com/open-telemetry/opentelemetry-cpp/pull/1650) * [SEMANTIC CONVENTIONS] Upgrade to version 1.14.0 [#1697](https://github.com/open-telemetry/opentelemetry-cpp/pull/1697) Notes: Metrics API/SDK GA release includes PRs [#1686](https://github.com/open-telemetry/opentelemetry-cpp/pull/1686), [#1701](https://github.com/open-telemetry/opentelemetry-cpp/pull/1701), and [#1707](https://github.com/open-telemetry/opentelemetry-cpp/pull/1707) with breaking changes in the Metrics API and SDK. ## [1.6.1] 2022-09-22 * [BUILD] Upgrade opentelemetry-proto to v0.19.0 [#1579](https://github.com/open-telemetry/opentelemetry-cpp/pull/1579) * [METRICS EXPORTER] Add `OtlpGrpcMetricExporterFactory` and `OtlpHttpMetricExporterFactory`. [#1606](https://github.com/open-telemetry/opentelemetry-cpp/pull/1606) * [SEMANTIC CONVENTIONS] Upgrade to version 1.13.0 [#1624](https://github.com/open-telemetry/opentelemetry-cpp/pull/1624) * [BUILD] Fixes span creation benchmark issue. [#1622](https://github.com/open-telemetry/opentelemetry-cpp/pull/1622) * [BUILD] Fix more build warnings (#1616) [#1620](https://github.com/open-telemetry/opentelemetry-cpp/pull/1620) * [SDK gRPC]: Fix out-of-bounds access of string_view in GrpcClientCarrier in the example [#1619](https://github.com/open-telemetry/opentelemetry-cpp/pull/1619) * [EXPORTER ETW] Add Trace flags in SpanContext [#1618](https://github.com/open-telemetry/opentelemetry-cpp/pull/1618) * [SDK] resource sdk: Update Resource::Merge function docs [#1615](https://github.com/open-telemetry/opentelemetry-cpp/pull/1615) * [BUILD] Fix build warnings [#1613](https://github.com/open-telemetry/opentelemetry-cpp/pull/1613) * [API BUILD] Fix header only api singletons (#1520) [#1604](https://github.com/open-telemetry/opentelemetry-cpp/pull/1604) * [METRICS SDK] Fix default value of `OtlpHttpMetricExporterOptions::aggregation_temporality`. [#1601](https://github.com/open-telemetry/opentelemetry-cpp/pull/1601) * [METRICS EXAMPLE] Example for OTLP gRPC exporter for Metrics. [#1598](https://github.com/open-telemetry/opentelemetry-cpp/pull/1598) * [SDK] Fix `LoggerContext::Shutdown` and tsan of `OtlpHttpClient` [#1592](https://github.com/open-telemetry/opentelemetry-cpp/pull/1592) * [METRICS SDK] Fix 1585 - Multiple cumulative metric collections without measurement recording. [#1586](https://github.com/open-telemetry/opentelemetry-cpp/pull/1586) * [BUILD] metrics warnings [#1583](https://github.com/open-telemetry/opentelemetry-cpp/pull/1583) * [METRICS SDK] Fix ObservableInstrument::RemoveCallback [#1582](https://github.com/open-telemetry/opentelemetry-cpp/pull/1582) * [SDK] Add error log when getting a http error code [#1581](https://github.com/open-telemetry/opentelemetry-cpp/pull/1581) * [EXPORTER] ETW Exporter - Add support for Sampler and ID Generator [#1547](https://github.com/open-telemetry/opentelemetry-cpp/pull/1547) Notes: While [OpenTelemetry semantic convention](https://github.com/open-telemetry/opentelemetry-specification/tree/main/semantic_conventions) is still in experimental state, PR [#1624](https://github.com/open-telemetry/opentelemetry-cpp/pull/1624) upgraded it from 1.12.0 to 1.13.0 which **MAY** break the instrumentation library. Please update the semantic convention in instrumentation library is needed. ## [1.6.0] 2022-08-15 * [METRICS SDK] Calling Observable Instruments callback during metrics collection [#1554](https://github.com/open-telemetry/opentelemetry-cpp/pull/1554) * [METRICS CI] Add CI jobs for new and deprecated metrics [#1531](https://github.com/open-telemetry/opentelemetry-cpp/pull/1531) * [METRICS BUILD] Fix metrics asan and tsan CI [#1562](https://github.com/open-telemetry/opentelemetry-cpp/pull/1562) * [METRICS SDK] remove throw check from metrics with noexcept [#1560](https://github.com/open-telemetry/opentelemetry-cpp/pull/1560) * [METRICS SDK] fix metrics race condition [#1552](https://github.com/open-telemetry/opentelemetry-cpp/pull/1552) * [METRICS SDK] Fix metrics context circular reference [#1535](https://github.com/open-telemetry/opentelemetry-cpp/pull/1535) * [METRICS EXPORTER] Improve scope/instrument names in metrics ostream exporter [#1544](https://github.com/open-telemetry/opentelemetry-cpp/pull/1544) * [METRICS BUILD] fix IWYU error in instruments.h [#1555](https://github.com/open-telemetry/opentelemetry-cpp/pull/1555) * [EXPORTER] Prometheus exporter support Gauge Type [#1553](https://github.com/open-telemetry/opentelemetry-cpp/pull/1553) * [METRICS SDK] Fix default Metric view name [#1515](https://github.com/open-telemetry/opentelemetry-cpp/pull/1515) * [SDK] Fix infinitely waiting when shutdown with more than one running http sessions. [#1549](https://github.com/open-telemetry/opentelemetry-cpp/pull/1549) * [METRICS SDK] Fix OTLP gRPC Metrics env variables [#1543](https://github.com/open-telemetry/opentelemetry-cpp/pull/1543) * [METRICS SDK] Metric aggregation temporality controls [#1541](https://github.com/open-telemetry/opentelemetry-cpp/pull/1541) * [METRICS SDK] Histogram min/max support [#1540](https://github.com/open-telemetry/opentelemetry-cpp/pull/1540) * [METRICS EXPORTER] ostream exporter should print out resource attributes [#1523](https://github.com/open-telemetry/opentelemetry-cpp/pull/1523) * [METRICS SDK] Support multiple async callbacks [#1495](https://github.com/open-telemetry/opentelemetry-cpp/pull/1495) * [BUILD] Fix code scanning alert [#1530](https://github.com/open-telemetry/opentelemetry-cpp/pull/1530) * [BUILD] Fix several compiling/linking errors [#1539](https://github.com/open-telemetry/opentelemetry-cpp/pull/1539) * [TRACE SDK] Add SpanData getter for Span Recordable [#1508](https://github.com/open-telemetry/opentelemetry-cpp/pull/1508) * [LOG SDK] Fix log sdk builder (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524) * [METRICS SDK] Add configuration options for Aggregation creation [#1513](https://github.com/open-telemetry/opentelemetry-cpp/pull/1513) * [METRICS TEST] Fix metrics unit test memory leack [#1533](https://github.com/open-telemetry/opentelemetry-cpp/pull/1533) * [LOG SDK] Add log sdk builders (#1486) [#1524](https://github.com/open-telemetry/opentelemetry-cpp/pull/1524) ## [1.5.0] 2022-07-29 * [EXPORTER BUILD] Add resources to dep list of prometheus exporter test [#1527](https://github.com/open-telemetry/opentelemetry-cpp/pull/1527) * [BUILD] Don't require applications using jaeger exporter to know about libcurl [#1518](https://github.com/open-telemetry/opentelemetry-cpp/pull/1518) * [EXPORTER] Inline print_value() in ostream exporter [#1512](https://github.com/open-telemetry/opentelemetry-cpp/pull/1512) * [SDK] fix: urlPaser will incorrect parsing url like `http://abc.com/xxx@xxx/a/b` [#1511](https://github.com/open-telemetry/opentelemetry-cpp/pull/1511) * [SDK] Rename `InstrumentationLibrary` to `InstrumentationScope` [#1507](https://github.com/open-telemetry/opentelemetry-cpp/pull/1507) * [BUILD] Try to build nlohmann-json only it's depended. [#1505](https://github.com/open-telemetry/opentelemetry-cpp/pull/1505) * [EXPORTER BUILD] Link opentelemetry_api to ETW exporter test [#1503](https://github.com/open-telemetry/opentelemetry-cpp/pull/1503) * [SDK] Add automatically semantic conventions from the spec (#873) [#1497](https://github.com/open-telemetry/opentelemetry-cpp/pull/1497) * [SDK] Use template class for in-memory data. [#1496](https://github.com/open-telemetry/opentelemetry-cpp/pull/1496) * [SDK] fix compiler warnings [#1499](https://github.com/open-telemetry/opentelemetry-cpp/pull/1499) * [TRACE SDK] Add trace sdk builders (#1393) [#1471](https://github.com/open-telemetry/opentelemetry-cpp/pull/1471) * [METRICS BUILD] Enable bazel build for metrics proto files [#1489](https://github.com/open-telemetry/opentelemetry-cpp/pull/1489) * [METRICS EXPORTER] Add metrics OTLP/HTTP exporter [#1487](https://github.com/open-telemetry/opentelemetry-cpp/pull/1487) * [EXPORTER] fix otlp grpc exporter naming [#1488](https://github.com/open-telemetry/opentelemetry-cpp/pull/1488) * [BUILD] Remove `--config Debug` when installing. [#1480](https://github.com/open-telemetry/opentelemetry-cpp/pull/1480) * [EXPORTER] Fix endpoint in otlp grpc exporter [#1474](https://github.com/open-telemetry/opentelemetry-cpp/pull/1474) * [EXAMPLE] Fix memory ownership of InMemorySpanExporter (#1473) [#1471](https://github.com/open-telemetry/opentelemetry-cpp/pull/1471) * [EXPORTER TESTS] Prometheus unit test [#1461](https://github.com/open-telemetry/opentelemetry-cpp/pull/1461) * [DOCS] Update docs to use relative code links. [#1447](https://github.com/open-telemetry/opentelemetry-cpp/pull/1447) * [SDK] Remove reference to deprecated InstrumentationLibrary in OTLP [#1469](https://github.com/open-telemetry/opentelemetry-cpp/pull/1469) * [SDK] Fix trace kIsSampled flag set incorrectly [#1465](https://github.com/open-telemetry/opentelemetry-cpp/pull/1465) * [METRICS EXPORTER] OTLP gRPC Metrics Exporter [#1454](https://github.com/open-telemetry/opentelemetry-cpp/pull/1454) * [EXPORTER] fix prometheus exporter failure type [#1460](https://github.com/open-telemetry/opentelemetry-cpp/pull/1460) * [SDK] Fix build warnings about missing aggregates. [#1368](https://github.com/open-telemetry/opentelemetry-cpp/pull/1368) * [EXT] `curl::HttpClient` use `curl_multi_handle` instead of creating a thread for every request and it's able to reuse connections now. ([#1317](https://github.com/open-telemetry/opentelemetry-cpp/pull/1317)) * [SEMANTIC CONVENTIONS] Upgrade to version 1.12.0 [#873](https://github.com/open-telemetry/opentelemetry-cpp/pull/873) ## [1.4.1] 2022-06-19 * [METRICS SDK] Fix variables inizialization [#1430](https://github.com/open-telemetry/opentelemetry-cpp/pull/1430) * [DOCS] Fixed broken link to OpenTelemetry.io (#1445) [#1446](https://github.com/open-telemetry/opentelemetry-cpp/pull/1446) * [BUILD] Upgrade nlohmann_json to 3.10.5 (#1438) [#1441](https://github.com/open-telemetry/opentelemetry-cpp/pull/1441) * [METRICS SDK] fix histogram [#1440](https://github.com/open-telemetry/opentelemetry-cpp/pull/1440) * [DOCS] Fix GettingStarted documentation for Jaeger HTTP exporter (#1347) [#1439](https://github.com/open-telemetry/opentelemetry-cpp/pull/1439) * [BUILD] install sdk-config.h [#1419](https://github.com/open-telemetry/opentelemetry-cpp/pull/1419) * [EXAMPLE] Log current timestamp instead of epoch time [#1434](https://github.com/open-telemetry/opentelemetry-cpp/pull/1434) * [METRICS SDK] Add attributes/dimensions to metrics ostream exporter [#1400](https://github.com/open-telemetry/opentelemetry-cpp/pull/1400) * [SDK] Fix global log handle symbols when using dlopen [#1420](https://github.com/open-telemetry/opentelemetry-cpp/pull/1420) * [METRICS] Only record non-negative / finite / Non-NAN histogram values([#1427](https://github.com/open-telemetry/opentelemetry-cpp/pull/1427)) * [ETW EXPORTER] Fix ETW log exporter header inclusion [#1426](https://github.com/open-telemetry/opentelemetry-cpp/pull/1426) * [ETW EXPORTER] Copy string_view passed to ETW exporter in PropertyVariant [#1425](https://github.com/open-telemetry/opentelemetry-cpp/pull/1425) * [METRICS API/SDK] Pass state to async callback function. [#1408](https://github.com/open-telemetry/opentelemetry-cpp/pull/1408) * [BUILD] fix nlohmann_json's (third party) include dir [#1415](https://github.com/open-telemetry/opentelemetry-cpp/pull/1415) * [SDK] fix: WaitOnSocket select error when sockfd above FD_SETSIZE [#1410](https://github.com/open-telemetry/opentelemetry-cpp/pull/1410) * [SDK] fix OTEL_INTERNAL_LOG_INFO [#1407](https://github.com/open-telemetry/opentelemetry-cpp/pull/1407) * [DOCS] Document Getting Started with Prometheus and Grafana [#1396](https://github.com/open-telemetry/opentelemetry-cpp/pull/1396) ## [1.4.0] 2022-05-17 * [API SDK] Upgrade proto to v0.17.0, update log data model ([#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383)) * [BUILD] Alpine image ([#1382](https://github.com/open-telemetry/opentelemetry-cpp/pull/1382)) * [LOGS SDK] Get span_id from context when Logger::Log received invalid span_id ([#1398](https://github.com/open-telemetry/opentelemetry-cpp/pull/1398)) * [METRICS SDK] Connect async storage with async instruments ([#1388](https://github.com/open-telemetry/opentelemetry-cpp/pull/1388)) * [DOCS] Getting started document using ostream exporter ([#1394](https://github.com/open-telemetry/opentelemetry-cpp/pull/1394)) * [BUILD] Fix missing link to nlohmann_json ([#1390](https://github.com/open-telemetry/opentelemetry-cpp/pull/1390)) * [SDK] Fix sharing resource in batched exported spans ([#1386](https://github.com/open-telemetry/opentelemetry-cpp/pull/1386)) * [PROTOCOL \& LOGS] Upgrade proto to v0.17.0, update log data model ([#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383)) * [METRICS SDK] Remove un-necessary files. ([#1379](https://github.com/open-telemetry/opentelemetry-cpp/pull/1379)) * [EXPORTER] Prometheus exporter meters and instrument name ([#1378](https://github.com/open-telemetry/opentelemetry-cpp/pull/1378)) * [API] Add noexcept/const qualifier at missing places for Trace API. ([#1374](https://github.com/open-telemetry/opentelemetry-cpp/pull/1374)) * [SDK] Fix empty tracestate header propagation ([#1373](https://github.com/open-telemetry/opentelemetry-cpp/pull/1373)) * [METRICS SDK] Reuse temporal metric storage for sync storage ([#1369](https://github.com/open-telemetry/opentelemetry-cpp/pull/1369)) * [SDK] Fix baggage propagation for empty/invalid baggage context ([#1367](https://github.com/open-telemetry/opentelemetry-cpp/pull/1367)) * [BUILD] Export opentelemetry_otlp_recordable ([#1365](https://github.com/open-telemetry/opentelemetry-cpp/pull/1365)) * [TESTS] Disable test on prometheus-cpp which not need ([#1363](https://github.com/open-telemetry/opentelemetry-cpp/pull/1363)) * [METRICS] Fix class member initialization order ([#1360](https://github.com/open-telemetry/opentelemetry-cpp/pull/1360)) * [METRICS SDK] Simplify SDK Configuration: Use View with default aggregation if no matching View is configured ([#1358](https://github.com/open-telemetry/opentelemetry-cpp/pull/1358)) * [BUILD] Add missing include guard ([#1357](https://github.com/open-telemetry/opentelemetry-cpp/pull/1357)) * [ETW EXPORTER] Fix scalar delete against array ([#1356](https://github.com/open-telemetry/opentelemetry-cpp/pull/1356)) * [ETW EXPORTER] Conditional include for codecvt header ([#1355](https://github.com/open-telemetry/opentelemetry-cpp/pull/1355)) * [BUILD] Use latest TraceLoggingDynamic.h ([#1354](https://github.com/open-telemetry/opentelemetry-cpp/pull/1354)) * [SDK] Add explicit type cast in baggage UrlDecode ([#1353](https://github.com/open-telemetry/opentelemetry-cpp/pull/1353)) * [METRICS SDK] Remove exporter registration to meter provider ([#1350](https://github.com/open-telemetry/opentelemetry-cpp/pull/1350)) * [METRICS SDK] Fix output time in metrics OStream exporter ([#1346](https://github.com/open-telemetry/opentelemetry-cpp/pull/1346)) * [BUILD] ostream metrics cmake ([#1344](https://github.com/open-telemetry/opentelemetry-cpp/pull/1344)) * [BUILD] Link `opentelemetry_ext` with `opentelemetry_api` ([#1336](https://github.com/open-telemetry/opentelemetry-cpp/pull/1336)) * [METRICS SDK] Enable metric collection for Async Instruments - Delta and Cumulative ([#1334](https://github.com/open-telemetry/opentelemetry-cpp/pull/1334)) * [BUILD] Dependencies image as artifact ([#1333](https://github.com/open-telemetry/opentelemetry-cpp/pull/1333)) * [EXAMPLE] Prometheus example ([#1332](https://github.com/open-telemetry/opentelemetry-cpp/pull/1332)) * [METRICS EXPORTER] Prometheus exporter ([#1331](https://github.com/open-telemetry/opentelemetry-cpp/pull/1331)) * [METRICS] Metrics histogram example ([#1330](https://github.com/open-telemetry/opentelemetry-cpp/pull/1330)) * [TESTS] Replace deprecated googletest API ([#1327](https://github.com/open-telemetry/opentelemetry-cpp/pull/1327)) * [BUILD] Fix Ninja path ([#1326](https://github.com/open-telemetry/opentelemetry-cpp/pull/1326)) * [API] Update yield logic for ARM processor ([#1325](https://github.com/open-telemetry/opentelemetry-cpp/pull/1325)) * [BUILD] Fix metrics compiler warnings ([#1328](https://github.com/open-telemetry/opentelemetry-cpp/pull/1328)) * [METRICS SDK] Implement Merge and Diff operation for Histogram Aggregation ([#1303](https://github.com/open-telemetry/opentelemetry-cpp/pull/1303)) Notes: While opentelemetry-cpp Logs are still in experimental stage, [#1383](https://github.com/open-telemetry/opentelemetry-cpp/pull/1383) updated opentelemetry-proto to 0.17.0, which includes some breaking change in the protocol, like [this](https://github.com/open-telemetry/opentelemetry-proto/pull/373). This makes `name` parameter for our log API unnecessary. However, this parameter is marked deprecated instead of being removed in this release, and it will be removed in future release. ## [1.3.0] 2022-04-11 * [ETW EXPORTER] ETW provider handle cleanup ([#1322](https://github.com/open-telemetry/opentelemetry-cpp/pull/1322)) * [BUILD] Move public definitions into `opentelemetry_api`. ([#1314](https://github.com/open-telemetry/opentelemetry-cpp/pull/1314)) * [METRICS] OStream example ([#1312](https://github.com/open-telemetry/opentelemetry-cpp/pull/1312)) * [BUILD] Rename `http_client_curl` to `opentelemetry_http_client_curl` ([#1301](https://github.com/open-telemetry/opentelemetry-cpp/pull/1301)) * [METRICS SDK] Add InstrumentationInfo and Resource to the metrics data to be exported. ([#1299](https://github.com/open-telemetry/opentelemetry-cpp/pull/1299)) * [TESTS] Add building test without RTTI ([#1294](https://github.com/open-telemetry/opentelemetry-cpp/pull/1294)) * [METRICS SDK] Implement periodic exporting metric reader ([#1286](https://github.com/open-telemetry/opentelemetry-cpp/pull/1286)) * [SDK] Bugfix: span SetAttribute crash ([#1283](https://github.com/open-telemetry/opentelemetry-cpp/pull/1283)) * [BUG] Remove implicitly deleted default constructor ([#1267](https://github.com/open-telemetry/opentelemetry-cpp/pull/1267)) * [METRICS SDK] Synchronous Metric collection (Delta , Cumulative) ([#1265](https://github.com/open-telemetry/opentelemetry-cpp/pull/1265)) * [METRICS SDK] Metrics exemplar round 1 ([#1264](https://github.com/open-telemetry/opentelemetry-cpp/pull/1264)) * [EXPORTER] Fix: use CURLOPT_TIMEOUT_MS to config OtlpHttpExporter's timeout instead of CURLOPT_TIMEOUT ([#1261](https://github.com/open-telemetry/opentelemetry-cpp/pull/1261)) * [EXPORTER] Jaeger Exporter - Populate Span Links ([#1251](https://github.com/open-telemetry/opentelemetry-cpp/pull/1251)) * [SDK] Reorder the destructor of members in LoggerProvider and TracerProvider ([#1245](https://github.com/open-telemetry/opentelemetry-cpp/pull/1245)) * [METRICS SDK] Enable metric collection from MetricReader ([#1241](https://github.com/open-telemetry/opentelemetry-cpp/pull/1241)) * [METRICS SDK] Asynchronous Aggregation storage ([#1232](https://github.com/open-telemetry/opentelemetry-cpp/pull/1232)) * [METRICS SDK] Synchronous Instruments - Aggregation Storage(s) creation for configured views ([#1219](https://github.com/open-telemetry/opentelemetry-cpp/pull/1219)) * [BUILD] Added s390x arch into CMake build. ([#1216](https://github.com/open-telemetry/opentelemetry-cpp/pull/1216)) * [API] Allow extension of the lifetime of ContextStorage. ([#1214](https://github.com/open-telemetry/opentelemetry-cpp/pull/1214)) * [METRICS SDK] Add Aggregation storage ([#1213](https://github.com/open-telemetry/opentelemetry-cpp/pull/1213)) * [TESTS] Fix ostream_log_test Mac ([#1208](https://github.com/open-telemetry/opentelemetry-cpp/pull/1208)) * [BUILD] Update grpc to v1.43.2 to support VS2022/MSVC 19.30 and bazel 5.0 ([#1207](https://github.com/open-telemetry/opentelemetry-cpp/pull/1207)) * [DOCS] Benchmark documentation ([#1205](https://github.com/open-telemetry/opentelemetry-cpp/pull/1205)) * [DOCS] Fix errors in SDK documentation ([#1201](https://github.com/open-telemetry/opentelemetry-cpp/pull/1201)) * [METRICS EXPORTER] Ostream metric exporter ([#1196](https://github.com/open-telemetry/opentelemetry-cpp/pull/1196)) * [Metrics SDK] Filtering metrics attributes ([#1191](https://github.com/open-telemetry/opentelemetry-cpp/pull/1191)) * [Metrics SDK] Sync and Async Instruments SDK ([#1184](https://github.com/open-telemetry/opentelemetry-cpp/pull/1184)) * [Metrics SDK] Add Aggregation as part of metrics SDK. ([#1178](https://github.com/open-telemetry/opentelemetry-cpp/pull/1178)) * [BUILD] Cmake: thrift requires boost headers, include them as Boost_INCLUDE_DIRS ([#1100](https://github.com/open-telemetry/opentelemetry-cpp/pull/1100)) Notes: [#1301](https://github.com/open-telemetry/opentelemetry-cpp/pull/1301) added `opentelemetry_` as prefix to http_client_curl library for resolving potential naming conflict, this could break existing cmake build if http_client_curl is listed as explicit dependency in user's cmake file. ## [1.2.0] 2022-01-31 * [CI] Continuous benchmark tests as part of the CI ([#1174](https://github.com/open-telemetry/opentelemetry-cpp/pull/1174)) * [API] Allow to use external abseil for bazel targets ([#1172](https://github.com/open-telemetry/opentelemetry-cpp/pull/1172)) * [EXPORTER] Importing gsl::span if std::span is not available ([#1167](https://github.com/open-telemetry/opentelemetry-cpp/pull/1167)) * [EXPORTER] Synchronized calls to Exporter::Export & Shutdown ([#1164](https://github.com/open-telemetry/opentelemetry-cpp/pull/1164)) * [EXPORTER] OTLP http exporter block thread ([#1163](https://github.com/open-telemetry/opentelemetry-cpp/pull/1163)) * [TESTS] Jaeger: ThriftSender unit test ([#1162](https://github.com/open-telemetry/opentelemetry-cpp/pull/1162)) * [EXPORTER] InMemorySpanExporter shutdown fix ([#1161](https://github.com/open-telemetry/opentelemetry-cpp/pull/1161)) * [EXPORTER] Fix leak in Jaeger exporter ([#1160](https://github.com/open-telemetry/opentelemetry-cpp/pull/1160)) * [TESTS] ZipkinExporter unit-tests ([#1155](https://github.com/open-telemetry/opentelemetry-cpp/pull/1155)) * [SDK] Logger: propagating resources through LoggerProvider ([#1154](https://github.com/open-telemetry/opentelemetry-cpp/pull/1154)) * [SDK] Logger: support for instrumentation library ([#1149](https://github.com/open-telemetry/opentelemetry-cpp/pull/1149)) * [SDK] Add log level for internal log of sdk ([#1147](https://github.com/open-telemetry/opentelemetry-cpp/pull/1147)) * [METRICS] Metrics SDK: View API ([#1110](https://github.com/open-telemetry/opentelemetry-cpp/pull/1110)) Notes on experimental features: [#1149](https://github.com/open-telemetry/opentelemetry-cpp/pull/1149) and [#1154](https://github.com/open-telemetry/opentelemetry-cpp/pull/1154) from above CHANGELOG introduced API changes which are not backward compatible with previous logs, please update API package to this release if `ENABLE_LOGS_PREVIEW` is turned on (it is turned off by default). ## [1.1.1] 2021-12-20 * [SDK] Rename OTEL_CPP_GET_ATTR macro, and define it using fully qualified attr function ([#1140](https://github.com/open-telemetry/opentelemetry-cpp/pull/1140)) * [SDK] Default resource attributes and attributes in OTEL_RESOURCE_ATTRIBUTES are missing when using Otlp*LogExporter ([#1082](https://github.com/open-telemetry/opentelemetry-cpp/pull/1082)) * [METRICS] Add Meter and MeterProvider in the SDK ([#1078](https://github.com/open-telemetry/opentelemetry-cpp/pull/1078)) * [EXPORTER] ZipkinExporter shutdown ([#1153](https://github.com/open-telemetry/opentelemetry-cpp/pull/1153)) * [EXPORTER] Jaeger exporter shutdown ([#1150](https://github.com/open-telemetry/opentelemetry-cpp/pull/1150)) * [EXPORTER] Bugfix: `jaeger::TUDPTransport::write` crash when `getaddrinfo` returns error ([#1116](https://github.com/open-telemetry/opentelemetry-cpp/pull/1116)) * [EXPORTER] Bugfix: Jaeger exporter: extend supported attributes types ([#1106](https://github.com/open-telemetry/opentelemetry-cpp/pull/1106)) * [EXPORTER] Fix otlp generates null span ids ([#1113](https://github.com/open-telemetry/opentelemetry-cpp/pull/1113)) * [EXPORTER] Jaeger bazel (Linux only) ([#1077](https://github.com/open-telemetry/opentelemetry-cpp/pull/1077)) * [DOCS] Add note on DLL support ([#1137](https://github.com/open-telemetry/opentelemetry-cpp/pull/1137)) * [DOCS] Improve the instructions for Bazel build ([#1136](https://github.com/open-telemetry/opentelemetry-cpp/pull/1136)) * [DOCS] Document dependencies ([#1119](https://github.com/open-telemetry/opentelemetry-cpp/pull/1119)) * [DOCS] Dockerfile for quick demo/troubleshooting purpose ([#905](https://github.com/open-telemetry/opentelemetry-cpp/pull/905)) * [TESTS] Fix data race in BM_ThreadYieldSpinLockThrashing ([#1099](https://github.com/open-telemetry/opentelemetry-cpp/pull/1099)) * [EXAMPLE] Otlp gRPC log example ([#1083](https://github.com/open-telemetry/opentelemetry-cpp/pull/1083)) * [BUILD] C++20 not Building with VS2019 ([#1144](https://github.com/open-telemetry/opentelemetry-cpp/pull/1144)) * [BUILD] Mark tags to bazel targets([#1075](https://github.com/open-telemetry/opentelemetry-cpp/pull/1075)) ## [1.1.0] 2021-11-19 * [BUILD] build release tarball when nlohmann-json not installed ([#1074](https://github.com/open-telemetry/opentelemetry-cpp/pull/1074)) * [SDK] Bugfix: regex is neither working on GCC 4.9.x ([#1069](https://github.com/open-telemetry/opentelemetry-cpp/pull/1069)) * [SDK] Improvement: span_id should not break strict aliasing. ([#1068](https://github.com/open-telemetry/opentelemetry-cpp/pull/1068)) * [EXAMPLE] OTLP HTTP log example ([#1062](https://github.com/open-telemetry/opentelemetry-cpp/pull/1062)) * [SDK] OTLP gRPC log export should fail after shutdown ([#1064](https://github.com/open-telemetry/opentelemetry-cpp/pull/1064)) * [BUILD] Building otlp exporter from the release tarball ([#1056](https://github.com/open-telemetry/opentelemetry-cpp/pull/1056)) * [METRICS] Move old metrics implementation to different directory, and rename targets to \_deprecated ([#1053](https://github.com/open-telemetry/opentelemetry-cpp/pull/1053)) * [EXPORTER] Add OTLP/gRPC Log Exporter ([#1048](https://github.com/open-telemetry/opentelemetry-cpp/pull/1048)) * [EXPORTER] Prometheus Exporter ([#1031](https://github.com/open-telemetry/opentelemetry-cpp/pull/1031)) * [EXPORTER] Add OTLP/HTTP Log Exporter ([#1030](https://github.com/open-telemetry/opentelemetry-cpp/pull/1030)) * [SDK] fix: issue 368- consistent namespace scope resolution ([#1008](https://github.com/open-telemetry/opentelemetry-cpp/pull/1008)) ## [1.0.1] 2021-10-21 * [EXPORTER] Exports span attributes to ETW ([#1021](https://github.com/open-telemetry/opentelemetry-cpp/pull/1021)) * [BUILD] cmake: add FindThrift.cmake find module method for thrift ([#1020](https://github.com/open-telemetry/opentelemetry-cpp/pull/1020)) * [BUILD] Fix nlohmann_json package dependency ([#1017](https://github.com/open-telemetry/opentelemetry-cpp/pull/1017)) * [EXPORTER] Change OTLP/HTTP default port from 4317 to 4318 ([#1018](https://github.com/open-telemetry/opentelemetry-cpp/pull/1018)) * [EXPORTER] ETW Log Exporter ([#1006](https://github.com/open-telemetry/opentelemetry-cpp/pull/1006)) * [API] Adding new Logger:log() method ([#1005](https://github.com/open-telemetry/opentelemetry-cpp/pull/1005)) * [EXPORTER] Remove scheme from OTLP endpoint before passing to gRPC ([#988](https://github.com/open-telemetry/opentelemetry-cpp/pull/988)) * [BUILD] Update opentelemetry-proto for bazel build to 0.9.0 ([#984](https://github.com/open-telemetry/opentelemetry-cpp/pull/984)) * [BUILD] Cross compling grpc_cpp_plugin not found bug ([#982](https://github.com/open-telemetry/opentelemetry-cpp/pull/982)) * [EXPORTER] Support environment variables for both `OtlpGrpcExporter` and `OtlpHttpExporter` ([#983](https://github.com/open-telemetry/opentelemetry-cpp/pull/983)) * [API/SDK] Add schema_url support to both Resource and InstrumentationLibrary ([#979](https://github.com/open-telemetry/opentelemetry-cpp/pull/979)) * [BUILD] Fix build issue where _memcpy_ was not declared in scope ([#985](https://github.com/open-telemetry/opentelemetry-cpp/issues/985)) ## [1.0.0] 2021-09-16 ### API * Document DefaultSpan, remove DefaultTracer ([#959](https://github.com/open-telemetry/opentelemetry-cpp/pull/959)) * Separate baggage<->Context api from Baggage Propagator ([#963](https://github.com/open-telemetry/opentelemetry-cpp/pull/963)) * Remove unused public API to_span_ptr ([#964](https://github.com/open-telemetry/opentelemetry-cpp/pull/964)) * :collision: Make span context management public ([#967](https://github.com/open-telemetry/opentelemetry-cpp/pull/967)) * Support determining parent span from Context while creating new Span ([#969](https://github.com/open-telemetry/opentelemetry-cpp/pull/969)) * :collision: Traces: Add note on experimental semantic convention implementation, prefix semantics headers with experimental tag ([#970](https://github.com/open-telemetry/opentelemetry-cpp/pull/970)) * Increment OPENTELEMETRY_ABI_VERSION_NO to 1 ([#980](https://github.com/open-telemetry/opentelemetry-cpp/pull/980)) ### SDK * Clean up `GetEnvironmentVariable` and remove unused variable under `NO_GETENV` ([#976](https://github.com/open-telemetry/opentelemetry-cpp/pull/976)) * :collision: Resources: Add note on experimental semantic convention implementation, prefix semantics headers with experimental tag ([#970](https://github.com/open-telemetry/opentelemetry-cpp/pull/970)) ### OTLP Exporter * :bug: Ignore status description if status code is not Error ([#962](https://github.com/open-telemetry/opentelemetry-cpp/pull/962)) * :collision: Make Otlp exporter configuration environment variables specs-compliant ([#974](https://github.com/open-telemetry/opentelemetry-cpp/pull/974)) ### Zipkin Exporter * :bug: Don't set parentId in case parentId is empty ([#943](https://github.com/open-telemetry/opentelemetry-cpp/pull/943)) * :rocket: Extend zipkin exporter with ability to provide headers ([#951](https://github.com/open-telemetry/opentelemetry-cpp/pull/951)) ### DOCS * :book: Add getting-started documentation for SDK: ([#942](https://github.com/open-telemetry/opentelemetry-cpp/pull/942)) * :book: Remove unnecessary spaces and spelling of gRPC in README ([#965](https://github.com/open-telemetry/opentelemetry-cpp/pull/965)) ### BUILD * Disable bazel build for gcc 4.8, upgrade versions for grpc(v1.39.1) and bazel(4.2.0), document bazel support ([#953](https://github.com/open-telemetry/opentelemetry-cpp/pull/953)) * Move CMake config template to cmake folder ([#958](https://github.com/open-telemetry/opentelemetry-cpp/pull/958)) * Enable CMake to search the new package variable `_ROOT` ([#975](https://github.com/open-telemetry/opentelemetry-cpp/pull/975)) * :bug: Do not override CMAKE_CXX_STANDARD ([#977](https://github.com/open-telemetry/opentelemetry-cpp/pull/977)) ### :construction: Experiemental Features (Will change in future) * Semantic Conventions for traces - As the specs is still experimental, the implementation will change in future. * Semantic Convention for resource - As the specs is still experimental, the implementation will change in future. * Logs and Metrics API & SDK - These are not compliant, and are behind feature flag. Not recommended to use for now. ## [1.0.0-rc4] 2021-08-04 * [EXPORTER] `BREAKING CHANGE` Fix default HTTP port for OTLP HTTP Exporter ([#939](https://github.com/open-telemetry/opentelemetry-cpp/pull/939)) * [API] Fix timeout calculation for Tracer::Flush() and Tracer::Close() ([#937](https://github.com/open-telemetry/opentelemetry-cpp/pull/937)) * [API] Fix for Stack::Resize that new_capacity is not assigned to capacity_ ([#934](https://github.com/open-telemetry/opentelemetry-cpp/pull/934)) * [SDK] Fix race condition in circular buffer simulation test ([#931](https://github.com/open-telemetry/opentelemetry-cpp/pull/931)) * [EXPORTER] Fix error logging in Jaeger Exporter ([#930](https://github.com/open-telemetry/opentelemetry-cpp/pull/930)) * [BUILD] Use latest grpc version (v1.39.0) for cmake build of otlp exporter ([#927](https://github.com/open-telemetry/opentelemetry-cpp/pull/927)) * [EXPORTER] Add Jaeger Thrift HTTP exporter ([#926](https://github.com/open-telemetry/opentelemetry-cpp/pull/926)) * [SDK] Move env-var read logic to common dir, and optional reading of env-var ([#924](https://github.com/open-telemetry/opentelemetry-cpp/pull/924)) * [EXPORTER] Remove recordable header from CMake install rules for exporters ([#923](https://github.com/open-telemetry/opentelemetry-cpp/pull/923)) * [EXPORTER] `BREAKING CHANGE` Rename Recordable to JaegerRecordable in Jaeger exporter ([#919](https://github.com/open-telemetry/opentelemetry-cpp/pull/919)) * [EXPORTER] `BREAKING CHANGE` Rename Jaeger exporter target ([#918](https://github.com/open-telemetry/opentelemetry-cpp/pull/918)) * [EXPORTER] Add Zipkin exporter example ([#917](https://github.com/open-telemetry/opentelemetry-cpp/pull/917)) * [EXPORTER] Bazel build for Zipkin exorter ([#916](https://github.com/open-telemetry/opentelemetry-cpp/pull/916)) * [BUILD] Allow to use local GSL ([#915](https://github.com/open-telemetry/opentelemetry-cpp/pull/915)) * [DOCS] Document vcpkg toolchain configuration ([#913](https://github.com/open-telemetry/opentelemetry-cpp/pull/913)) * [SDK] Fix for resource deletion after tracer provider shutdown ([#911](https://github.com/open-telemetry/opentelemetry-cpp/pull/911)) * [BUILD] Add bazel build for grpc example ([#910](https://github.com/open-telemetry/opentelemetry-cpp/pull/910)) * [EXPORTER] Add resource and instrumentation library support for OStreamSpanExporter ([#906](https://github.com/open-telemetry/opentelemetry-cpp/pull/906)) * [API] Adding semantic-convention attributes for trace ([#868](https://github.com/open-telemetry/opentelemetry-cpp/pull/868)) ## [1.0.0-rc3] 2021-07-12 * [DOCS] Add doxygen reference docs for SDK ([#902](https://github.com/open-telemetry/opentelemetry-cpp/pull/902)) * [EXPORTER] Jaeger Exporter - Populate resource attributes into process tags in Jaeger ([#897](https://github.com/open-telemetry/opentelemetry-cpp/pull/897)) * [EXPORTER] Zipkin Exporter - Report Event timestamp into microseconds ([#896](https://github.com/open-telemetry/opentelemetry-cpp/pull/896)) * [EXPORTER] Jaeger Exporter - Handle span events ([#895](https://github.com/open-telemetry/opentelemetry-cpp/pull/895)) * [DOCS] Fix API docs for Scope object ([#894](https://github.com/open-telemetry/opentelemetry-cpp/pull/894)) * [BUILD] Fix Linking error for libcurl on some macOS environments ([#893](https://github.com/open-telemetry/opentelemetry-cpp/pull/893)) * [API] Context cleanup from Runtime Storage ([#885](https://github.com/open-telemetry/opentelemetry-cpp/pull/885)) * [DOCS] Document strategy to avoid conflict between two different versions of Abseil ([#883](https://github.com/open-telemetry/opentelemetry-cpp/pull/883/)) * [EXPORTER] ETW Exporter - Document example for ETW Exporter ([#882](https://github.com/open-telemetry/opentelemetry-cpp/pull/882)) * [SDK] Create Span with Valid spanId and traceId irrespective of Sampling decision ([#879](https://github.com/open-telemetry/opentelemetry-cpp/pull/879)) * [EXPORTER] Jaeger Exporter - Rename bswap macros to avoid clash on some systems ([#876](https://github.com/open-telemetry/opentelemetry-cpp/pull/876)) * [API] Add Semantics Conventions attributes for Resources ([#872](https://github.com/open-telemetry/opentelemetry-cpp/pull/872)) * [BUILD] Use nlohmann-json from submodules if not already installed ([#870](https://github.com/open-telemetry/opentelemetry-cpp/pull/870)) ## [1.0.0-rc2] 2021-06-18 * [EXPORTER] Jaeger Exporter - Support for Instrumentation Library ([#864](https://github.com/open-telemetry/opentelemetry-cpp/pull/864)) * [TESTS] Adding benchmark tests for baggage api ([#861](https://github.com/open-telemetry/opentelemetry-cpp/pull/861)) * [BUILD] Fix for GCC9/C++20 Support for using STL for modern C++ features ([#860](https://github.com/open-telemetry/opentelemetry-cpp/pull/860)) * [TESTS] Adding benchmark tests for span create api ([#856](https://github.com/open-telemetry/opentelemetry-cpp/pull/856)) * [BUILD] Fix for using Abseil library for modern C++ features ([#850](https://github.com/open-telemetry/opentelemetry-cpp/pull/850)) * [BUILD] Fix issues with win32/x86 compilation ([#847](https://github.com/open-telemetry/opentelemetry-cpp/pull/847)) * [DOCS] Document OSS dependencies and their licenses ([#844](https://github.com/open-telemetry/opentelemetry-cpp/pull/844)) * [BUILD] Various fixes to build with Visual Studio 2015 ([#840](https://github.com/open-telemetry/opentelemetry-cpp/pull/840)) * [INSTRUMENTATION] HTTPClient: Change support for full URL argument ([#833](https://github.com/open-telemetry/opentelemetry-cpp/pull/833)) * [EXPORTER] Jaeger Exporter - fix endianness of Jaeger IDs for transmission ([#832](https://github.com/open-telemetry/opentelemetry-cpp/pull/832)) * [INSTRUMENTATION] fix protobuf compilation warning in gRPC example ([#830](https://github.com/open-telemetry/opentelemetry-cpp/pull/830)) * [EXPORTER] `BREAKING CHANGE` - Add OTLP/HTTP+JSON Protocol exporter; Rename `OtlpExporter` to `OtlpGrpcExporter` ([#810](https://github.com/open-telemetry/opentelemetry-cpp/pull/810)) ## [1.0.0-rc1] 2021-06-04 * [BUILD] Enable Jaeger exporter build in Windows ([#815](https://github.com/open-telemetry/opentelemetry-cpp/pull/815)) * [DOCS] Versioning doc update to clarify release and versioning policy ([#811](https://github.com/open-telemetry/opentelemetry-cpp/pull/811)) * [LOGS] Move Logging implementation under feature-flag ([#807](https://github.com/open-telemetry/opentelemetry-cpp/pull/807)) * [BUILD] Filter metric headers files from `opentelemetry-api` and `opentelemetry-sdk` targets if metrics feature-flag is disabled ([#806](https://github.com/open-telemetry/opentelemetry-cpp/pull/806)) * [BUILD] Fix install rule for ostream exporter, Jaeger, ETW, ElasticSearch ([#805](Fix install rule for header files of ostream exporter)) * [API/SDK] Switch from mpark::variant to absl::variant as default ([#771](https://github.com/open-telemetry/opentelemetry-cpp/pull/771)) * [API/SDK] Support `const char *` as acceptable data type for attributes and resources ([#771](https://github.com/open-telemetry/opentelemetry-cpp/pull/771)) * [EXAMPLE] gRPC instrumentation example with context propagation ([#729](https://github.com/open-telemetry/opentelemetry-cpp/pull/729)) ## [0.7.0] 2021-05-26 * [METRICS] Move metrics api/sdk under preview feature flag ([#745](https://github.com/open-telemetry/opentelemetry-cpp/pull/745)) * [DOCS] Add instructions to build using Bazel ([#747](https://github.com/open-telemetry/opentelemetry-cpp/pull/747)) * [DOCS] Update copyright headers ([#754](https://github.com/open-telemetry/opentelemetry-cpp/pull/754)) * [EXPORTER] Populate resource to OTLP proto data ([#758](https://github.com/open-telemetry/opentelemetry-cpp/pull/758)) * [CI] Add CodeQL security scan CI workflow ([#770](https://github.com/open-telemetry/opentelemetry-cpp/pull/770)) * [BUILD] Enable building API only CMake Project ([#778](https://github.com/open-telemetry/opentelemetry-cpp/pull/778)) * [SDK] Fix for sampling of root span ([#784](https://github.com/open-telemetry/opentelemetry-cpp/pull/784)) * [CI] Add Jaeger exporter to CMake CI build ([#786](https://github.com/open-telemetry/opentelemetry-cpp/pull/786)) * [API] `BREAKING CHANGE` - Tracer::WithActiveSpan() to return Scope object intead of unique_ptr ([#788](https://github.com/open-telemetry/opentelemetry-cpp/pull/788)) * [DOCS] Add docs for nested spans and context propagation in readthedocs ([#792](https://github.com/open-telemetry/opentelemetry-cpp/pull/792)) * [CI] Output verbose error for failed unit-test in CI ([#796](https://github.com/open-telemetry/opentelemetry-cpp/pull/796)) ## [0.6.0] 2021-05-11 * [EXPORTER] Add Jaeger exporter ([#534](https://github.com/open-telemetry/opentelemetry-cpp/pull/534)) * [SDK] Support multiple processors ([#692](https://github.com/open-telemetry/opentelemetry-cpp/pull/692)) * [SDK] Add instrumentation library and multiple tracer support ([#693](https://github.com/open-telemetry/opentelemetry-cpp/pull/693)) * [SDK] Resource integration with Exporters ([#706](https://github.com/open-telemetry/opentelemetry-cpp/pull/706)) * [EXAMPLE] Enhance existing http example with propagation ([#727](https://github.com/open-telemetry/opentelemetry-cpp/pull/727)) ## [0.5.0] 2021-04-26 * [SDK] Support custom span-id and trace-id generator ([#681](https://github.com/open-telemetry/opentelemetry-cpp/pull/681)) * [SDK] Add SpanContext (and TraceState) to Recordable ([#667](https://github.com/open-telemetry/opentelemetry-cpp/pull/667)) * [SDK] Global Propagator ([#668](https://github.com/open-telemetry/opentelemetry-cpp/pull/668)) * [SDK] Create SharedContext for updating span pipeline ([#650](https://github.com/open-telemetry/opentelemetry-cpp/pull/650)) * [API] Baggage implementation ([#676](https://github.com/open-telemetry/opentelemetry-cpp/pull/676)) * [API] Move class from opentelemetry::core namespace to opentelemetry::common namespace ([#686](https://github.com/open-telemetry/opentelemetry-cpp/pull/686)) ## [0.4.0] 2021-04-12 * [EXPORTER] ETW Exporter enhancements ([#519](https://github.com/open-telemetry/opentelemetry-cpp/pull/519)) * [EXPORTER] Read Zipkin endpoint from environment variable. ([#624](https://github.com/open-telemetry/opentelemetry-cpp/pull/624)) * [EXPORTER] Split Zpages webserver hosting from Exporter ([#626](https://github.com/open-telemetry/opentelemetry-cpp/pull/626)) * [EXPORTER] ETW Exporter Usage Instructions ([#628](https://github.com/open-telemetry/opentelemetry-cpp/pull/628)) * [INSTRUMENTATION] HTTP Client/Server Instrumentation example ([#632](https://github.com/open-telemetry/opentelemetry-cpp/pull/632)) * [EXPORTER] Enable tls authentication for otlp grpc exporter ([#635](Enable tls authentication for otlp grpc exporter)) * [API] Refactoring trace_state to reuse common functionality in baggage ([#638](https://github.com/open-telemetry/opentelemetry-cpp/pull/638/files)) ## [0.3.0] 2021-03-19 * [EXPORTER] Added Zipkin Exporter. ([#471](https://github.com/open-telemetry/opentelemetry-cpp/pull/471)) * [API] Added Jaeger propagator. ([#599](https://github.com/open-telemetry/opentelemetry-cpp/pull/599)) * [PROPAGATOR] Added Composite Propagator ([#597](https://github.com/open-telemetry/opentelemetry-cpp/pull/597)) * [API] Propagate traceflag from parent ([#603](https://github.com/open-telemetry/opentelemetry-cpp/pull/603)) * [DOCS] Add sphinx support for api doc generation ([595](https://github.com/open-telemetry/opentelemetry-cpp/pull/595)) * [SDK] Add service.name if missing in Resource ([#616](https://github.com/open-telemetry/opentelemetry-cpp/pull/616)) ## [0.2.0] 2021-03-02 * [SDK] Added `ForceFlush` to `TracerProvider`. ([#588](https://github.com/open-telemetry/opentelemetry-cpp/pull/588)). * [SDK] Added Resource API. ([#502](https://github.com/open-telemetry/opentelemetry-cpp/pull/502)) * [API] Modified TraceState support for w3c trace context as per specs. * [SDK] TraceState implementation as per spec ([#551](https://github.com/open-telemetry/opentelemetry-cpp/pull/551)) * [API] Added B3 Propagator. ([#523](https://github.com/open-telemetry/opentelemetry-cpp/pull/523)) * [Exporter] Added ETW Exporter. ([#376](https://github.com/open-telemetry/opentelemetry-cpp/pull/376)) * [CI] Enable cache for Bazel for faster builds. ([#505](https://github.com/open-telemetry/opentelemetry-cpp/pull/505)) ## [0.0.1] 2020-12-16 ### Added * Trace API and SDK experimental * OTLP Exporter ### Changed ### Removed opentelemetry-cpp-1.19.0/CMakeLists.txt000066400000000000000000000641701474412371400200350ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 cmake_minimum_required(VERSION 3.10) # See https://cmake.org/cmake/help/latest/policy/CMP0074.html required by # certain version of zlib which CURL depends on. if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") cmake_policy(SET CMP0074 NEW) endif() # Allow to use normal variable for option() if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") cmake_policy(SET CMP0077 NEW) endif() # Prefer CMAKE_MSVC_RUNTIME_LIBRARY if possible if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) endif() # MSVC RTTI flag /GR should not be not added to CMAKE_CXX_FLAGS by default. @see # https://cmake.org/cmake/help/latest/policy/CMP0117.html if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20.0") cmake_policy(SET CMP0117 NEW) endif() project(opentelemetry-cpp) # Mark variables as used so cmake doesn't complain about them mark_as_advanced(CMAKE_TOOLCHAIN_FILE) # Prefer cmake CONFIG to auto resolve dependencies. set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) # Don't use customized cmake modules if vcpkg is used to resolve dependence. if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") endif() if(EXISTS "${CMAKE_SOURCE_DIR}/third_party_release") file(STRINGS "${CMAKE_SOURCE_DIR}/third_party_release" third_party_tags) foreach(third_party ${third_party_tags}) string(REGEX REPLACE "^[ ]+" "" third_party ${third_party}) string(REGEX MATCH "^[^=]+" third_party_name ${third_party}) string(REPLACE "${third_party_name}=" "" third_party_tag ${third_party}) set(${third_party_name} "${third_party_tag}") endforeach() endif() if(DEFINED ENV{ARCH}) # Architecture may be specified via ARCH environment variable set(ARCH $ENV{ARCH}) else() # Autodetection logic that populates ARCH variable if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") # Windows may report AMD64 even if target is 32-bit if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH x64) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(ARCH x86) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") # Windows may report x86 even if target is 64-bit if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH x64) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) set(ARCH x86) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc") # AIX will report the processor as 'powerpc' even if building in 64-bit mode if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH ppc64) else() set(ARCH ppc32) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") set(ARCH arm64) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") set(ARCH arm) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le") set(ARCH ppc64le) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") set(ARCH ppc64) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(mips.*|MIPS.*)") set(ARCH mips) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv.*|RISCV.*)") set(ARCH riscv) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(s390x.*|S390X.*)") set(ARCH s390x) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(sparc.*|SPARC.*)") set(ARCH sparc) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(loongarch.*|LOONGARCH.*)") set(ARCH loongarch) else() message( FATAL_ERROR "opentelemetry-cpp: unrecognized target processor ${CMAKE_SYSTEM_PROCESSOR} configuration!" ) endif() endif() message(STATUS "Building for architecture ARCH=${ARCH}") # Autodetect vcpkg toolchain if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") endif() if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE) include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") endif() option(WITH_ABI_VERSION_1 "ABI version 1" ON) option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF) file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" OPENTELEMETRY_CPP_HEADER_VERSION_H) # # We do not want to have WITH_ABI_VERSION = "1" or "2", and instead prefer two # distinct flags, WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2. # # This allows: # # * to have a specific option description for each ABI # * to mark experimental/stable/deprecated on flags, for clarity # * to search for exact abi usage move easily, discouraging: # # * cmake -DWITH_ABI_VERSION=${ARG} # # While not supported, having distinct WITH_ABI_VERSION_1 and WITH_ABI_VERSION_2 # flags also opens the possibility to support multiple ABI concurrently, should # that become necessary. # if(WITH_ABI_VERSION_1 AND WITH_ABI_VERSION_2) # # Only one ABI is supported in a build. # message( FATAL_ERROR "Set either WITH_ABI_VERSION_1 or WITH_ABI_VERSION_2, not both") endif() if(WITH_ABI_VERSION_2) set(OPENTELEMETRY_ABI_VERSION_NO "2") elseif(WITH_ABI_VERSION_1) set(OPENTELEMETRY_ABI_VERSION_NO "1") else() if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES "OPENTELEMETRY_ABI_VERSION_NO[ \t\r\n]+\"?([0-9]+)\"?") math(EXPR OPENTELEMETRY_ABI_VERSION_NO ${CMAKE_MATCH_1}) else() message( FATAL_ERROR "OPENTELEMETRY_ABI_VERSION_NO not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" ) endif() endif() message(STATUS "OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}") if(OPENTELEMETRY_CPP_HEADER_VERSION_H MATCHES "OPENTELEMETRY_VERSION[ \t\r\n]+\"?([^\"]+)\"?") set(OPENTELEMETRY_VERSION ${CMAKE_MATCH_1}) else() message( FATAL_ERROR "OPENTELEMETRY_VERSION not found on ${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" ) endif() message(STATUS "OPENTELEMETRY_VERSION=${OPENTELEMETRY_VERSION}") option(WITH_NO_DEPRECATED_CODE "Do not include deprecated code" OFF) set(WITH_STL "OFF" CACHE STRING "Which version of the Standard Library for C++ to use") option(WITH_GSL "Whether to use Guidelines Support Library for C++ latest features" OFF) option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF) set(OPENTELEMETRY_INSTALL_default ON) if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(OPENTELEMETRY_INSTALL_default OFF) endif() option(OPENTELEMETRY_INSTALL "Whether to install opentelemetry targets" ${OPENTELEMETRY_INSTALL_default}) include("${PROJECT_SOURCE_DIR}/cmake/tools.cmake") if(NOT WITH_STL STREQUAL "OFF") # These definitions are needed for test projects that do not link against # opentelemetry-api library directly. We ensure that variant implementation # (absl::variant or std::variant) in variant unit test code is consistent with # the global project build definitions. Optimize for speed to reduce the hops if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") if(CMAKE_BUILD_TYPE MATCHES Debug) # Turn off optimizations for DEBUG set(MSVC_CXX_OPT_FLAG "/Od") else() string(REGEX MATCH "\/O" result ${CMAKE_CXX_FLAGS}) if(NOT ${result} MATCHES "\/O") set(MSVC_CXX_OPT_FLAG "/O2") endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_OPT_FLAG}") endif() endif() option(WITH_OTLP_RETRY_PREVIEW "Whether to enable experimental retry functionality" OFF) option(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW "Whether to enable mTLS support fro gRPC" OFF) option(WITH_OTLP_GRPC "Whether to include the OTLP gRPC exporter in the SDK" OFF) option(WITH_OTLP_HTTP "Whether to include the OTLP http exporter in the SDK" OFF) option(WITH_OTLP_FILE "Whether to include the OTLP file exporter in the SDK" OFF) option( WITH_OTLP_HTTP_COMPRESSION "Whether to include gzip compression for the OTLP http exporter in the SDK" OFF) option(WITH_CURL_LOGGING "Whether to enable select CURL verbosity in OTel logs" OFF) option(WITH_ZIPKIN "Whether to include the Zipkin exporter in the SDK" OFF) option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK" OFF) option(WITH_ELASTICSEARCH "Whether to include the Elasticsearch Client in the SDK" OFF) option(WITH_NO_GETENV "Whether the platform supports environment variables" OFF) option(BUILD_TESTING "Whether to enable tests" ON) option(WITH_BENCHMARK "Whether to build benchmark program" ON) option(BUILD_W3CTRACECONTEXT_TEST "Whether to build w3c trace context" OFF) option(OTELCPP_MAINTAINER_MODE "Build in maintainer mode (-Wall -Werror)" OFF) option(WITH_OPENTRACING "Whether to include the Opentracing shim" OFF) option(OTELCPP_VERSIONED_LIBS "Whether to generate the versioned shared libs" OFF) # # This option is experimental, subject to change in the spec: # # * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 # option(WITH_REMOVE_METER_PREVIEW "EXPERIMENTAL, ABI BREAKING: Allow to remove a meter" OFF) if(OTELCPP_VERSIONED_LIBS AND NOT BUILD_SHARED_LIBS) message(FATAL_ERROR "OTELCPP_VERSIONED_LIBS=ON requires BUILD_SHARED_LIBS=ON") endif() if(WIN32) option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON) else() if(DEFINED (WITH_ETW)) message(FATAL_ERROR "WITH_ETW is only supported on Windows") endif() endif(WIN32) # Do not convert deprecated message to error if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") add_compile_options(-Wno-error=deprecated-declarations) endif() option( WITH_API_ONLY "Only build the API (use as a header-only library). Overrides WITH_EXAMPLES and all options to enable exporters" OFF) option(WITH_EXAMPLES "Whether to build examples" ON) # This requires CURL, OFF by default. option( WITH_EXAMPLES_HTTP "Whether to build http client/server examples. Requires WITH_EXAMPLES and CURL" OFF) option(WITH_FUNC_TESTS "Whether to build functional tests" ON) option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF) # Exemplar specs status is experimental, so behind feature flag by default option(WITH_METRICS_EXEMPLAR_PREVIEW "Whether to enable exemplar within metrics" OFF) # Experimental, so behind feature flag by default option(WITH_THREAD_INSTRUMENTATION_PREVIEW "Whether to enable thread instrumentation" OFF) option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS "Whether to build test libraries that are always linked as shared libs" OFF) # # Verify options dependencies # if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES) message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON") endif() find_package(Threads) function(install_windows_deps) # Bootstrap vcpkg from CMake and auto-install deps in case if we are missing # deps on Windows. Respect the target architecture variable. set(VCPKG_TARGET_ARCHITECTURE ${ARCH} PARENT_SCOPE) message(STATUS "Installing build tools and dependencies...") set(ENV{ARCH} ${ARCH}) execute_process( COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd) set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "") message( STATUS "Make sure that vcpkg.cmake is set as the CMAKE_TOOLCHAIN_FILE at the START of the cmake build process! Can be command-line arg (cmake -DCMAKE_TOOLCHAIN_FILE=...) or set in your editor of choice." ) endfunction() function(set_target_version target_name) if(OTELCPP_VERSIONED_LIBS) set_target_properties( ${target_name} PROPERTIES VERSION ${OPENTELEMETRY_VERSION} SOVERSION ${OPENTELEMETRY_ABI_VERSION_NO}) endif() endfunction() if(MSVC) # Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value # for recent C++ language standards. Without this option MSVC returns the # value of __cplusplus="199711L" if(MSVC_VERSION GREATER 1900) # __cplusplus flag is not supported by Visual Studio 2015 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") endif() endif() # include GNUInstallDirs before include cmake/opentelemetry-proto.cmake because # opentelemetry-proto installs targets to the location variables defined in # GNUInstallDirs. include(GNUInstallDirs) if(WITH_PROMETHEUS) find_package(prometheus-cpp CONFIG QUIET) if(NOT prometheus-cpp_FOUND) message(STATUS "Trying to use local prometheus-cpp from submodule") if(EXISTS ${PROJECT_SOURCE_DIR}/third_party/prometheus-cpp/.git) set(SAVED_ENABLE_TESTING ${ENABLE_TESTING}) set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) set(ENABLE_TESTING OFF) set(CMAKE_CXX_CLANG_TIDY "") set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "") add_subdirectory(third_party/prometheus-cpp) set(ENABLE_TESTING ${SAVED_ENABLE_TESTING}) set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) else() message( FATAL_ERROR "\nprometheus-cpp package was not found. Please either provide it manually or clone with submodules. " "To initialize, fetch and checkout any nested submodules, you can use the following command:\n" "git submodule update --init --recursive") endif() else() message(STATUS "Using external prometheus-cpp") endif() endif() if(WITH_ABSEIL) if(NOT TARGET absl::strings) find_package(absl CONFIG REQUIRED) endif() endif() if(WITH_OTLP_GRPC OR WITH_OTLP_HTTP OR WITH_OTLP_FILE) find_package(Protobuf) # Protobuf 3.22 or upper require abseil-cpp, we can find it in # opentelemetry-cpp-config.cmake if(WITH_OTLP_GRPC) find_package(gRPC) endif() if((NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) OR (WITH_OTLP_GRPC AND NOT gRPC_FOUND)) if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) install_windows_deps() endif() if(WIN32 AND (NOT DEFINED CMAKE_TOOLCHAIN_FILE)) message(FATAL_ERROR "Windows dependency installation failed!") endif() if(WIN32) include(${CMAKE_TOOLCHAIN_FILE}) endif() if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND) find_package(Protobuf REQUIRED) endif() if(NOT gRPC_FOUND AND WITH_OTLP_GRPC) find_package(gRPC) endif() if(WIN32) # Always use x64 protoc.exe if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}") set(Protobuf_PROTOC_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/packages/protobuf_x64-windows/tools/protobuf/protoc.exe ) endif() endif() endif() # Latest Protobuf imported targets and without legacy module support if(TARGET protobuf::protoc) if(CMAKE_CROSSCOMPILING AND Protobuf_PROTOC_EXECUTABLE) set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) else() project_build_tools_get_imported_location(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) # If protobuf::protoc is not a imported target, then we use the target # directly for fallback if(NOT PROTOBUF_PROTOC_EXECUTABLE) set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc) endif() endif() elseif(Protobuf_PROTOC_EXECUTABLE) # Some versions of FindProtobuf.cmake uses mixed case instead of uppercase set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE}) endif() include(CMakeDependentOption) message(STATUS "PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}") set(SAVED_CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY}) set(CMAKE_CXX_CLANG_TIDY "") include(cmake/opentelemetry-proto.cmake) set(CMAKE_CXX_CLANG_TIDY ${SAVED_CMAKE_CXX_CLANG_TIDY}) endif() # # Do we need HTTP CLIENT CURL ? # if(WITH_OTLP_HTTP OR WITH_ELASTICSEARCH OR WITH_ZIPKIN OR BUILD_W3CTRACECONTEXT_TEST OR WITH_EXAMPLES_HTTP) set(WITH_HTTP_CLIENT_CURL ON) else() set(WITH_HTTP_CLIENT_CURL OFF) endif() # # Do we need CURL ? # if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL) # No specific version required. find_package(CURL REQUIRED) message(STATUS "Found CURL: ${CURL_LIBRARIES}, version ${CURL_VERSION}") endif() # # Do we need ZLIB ? # if((NOT WITH_API_ONLY) AND WITH_HTTP_CLIENT_CURL AND WITH_OTLP_HTTP_COMPRESSION) # No specific version required. find_package(ZLIB REQUIRED) message(STATUS "Found ZLIB: ${ZLIB_LIBRARIES}, version ${ZLIB_VERSION}") endif() # # Do we need NLOHMANN_JSON ? # if(WITH_ELASTICSEARCH OR WITH_ZIPKIN OR WITH_OTLP_HTTP OR WITH_OTLP_FILE OR BUILD_W3CTRACECONTEXT_TEST OR WITH_ETW) set(USE_NLOHMANN_JSON ON) else() set(USE_NLOHMANN_JSON OFF) endif() if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON) include(cmake/nlohmann-json.cmake) endif() if(OTELCPP_MAINTAINER_MODE) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") message(STATUS "Building with gcc in maintainer mode.") add_compile_options(-Wall) add_compile_options(-Werror) add_compile_options(-Wextra) # Tested with GCC 9.4 on github. if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.4) message(STATUS "Building with additional warnings for gcc.") # Relaxed warnings # Enforced warnings # C++ options only add_compile_options($<$,CXX>:-Wextra-semi>) add_compile_options( $<$,CXX>:-Woverloaded-virtual>) add_compile_options( $<$,CXX>:-Wsuggest-override>) add_compile_options( $<$,CXX>:-Wold-style-cast>) # C and C++ add_compile_options(-Wcast-qual) add_compile_options(-Wformat-security) add_compile_options(-Wlogical-op) add_compile_options(-Wmissing-include-dirs) add_compile_options(-Wstringop-truncation) add_compile_options(-Wundef) add_compile_options(-Wvla) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") message(STATUS "Building with clang in maintainer mode.") add_compile_options(-Wall) add_compile_options(-Werror) add_compile_options(-Wextra) # Tested with Clang 11.0 on github. if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) message(STATUS "Building with additional warnings for clang.") # Relaxed warnings add_compile_options(-Wno-error=unused-private-field) # Enforced warnings add_compile_options(-Wcast-qual) add_compile_options(-Wconditional-uninitialized) add_compile_options(-Wextra-semi) add_compile_options(-Wformat-security) add_compile_options(-Wheader-hygiene) add_compile_options(-Winconsistent-missing-destructor-override) add_compile_options(-Winconsistent-missing-override) add_compile_options(-Wnewline-eof) add_compile_options(-Wnon-virtual-dtor) add_compile_options(-Woverloaded-virtual) add_compile_options(-Wrange-loop-analysis) add_compile_options(-Wundef) add_compile_options(-Wundefined-reinterpret-cast) add_compile_options(-Wvla) add_compile_options(-Wold-style-cast) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message(STATUS "Building with msvc in maintainer mode.") add_compile_options(/WX) add_compile_options(/W4) # Relaxed warnings add_compile_options(/wd4100) add_compile_options(/wd4125) add_compile_options(/wd4566) add_compile_options(/wd4127) add_compile_options(/wd4512) add_compile_options(/wd4267) # Enforced warnings add_compile_options(/we4265) # 'class': class has virtual functions, but # destructor is not virtual add_compile_options(/we5204) # A class with virtual functions has # non-virtual trivial destructor. elseif() message(FATAL_ERROR "Building with unknown compiler in maintainer mode.") endif() endif(OTELCPP_MAINTAINER_MODE) list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") include(CTest) if(BUILD_TESTING) if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a) # Prefer GTest from build tree. GTest is not always working with # CMAKE_PREFIX_PATH set(GTEST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include) if(TARGET gtest) set(GTEST_BOTH_LIBRARIES gtest gtest_main) else() set(GTEST_BOTH_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libgtest.a ${CMAKE_BINARY_DIR}/lib/libgtest_main.a) endif() elseif(WIN32) # Make sure we are always bootsrapped with vcpkg on Windows find_package(GTest) if(NOT (GTEST_FOUND OR GTest_FOUND)) if(DEFINED CMAKE_TOOLCHAIN_FILE) message( FATAL_ERROR "Pleaes install GTest with the CMAKE_TOOLCHAIN_FILE at ${CMAKE_TOOLCHAIN_FILE}" ) else() install_windows_deps() include(${CMAKE_TOOLCHAIN_FILE}) find_package(GTest REQUIRED) endif() endif() else() # Prefer GTest installed by OS distro, brew or vcpkg package manager find_package(GTest REQUIRED) endif() if(NOT GTEST_BOTH_LIBRARIES) # New GTest package names if(TARGET GTest::gtest) set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main) elseif(TARGET GTest::GTest) set(GTEST_BOTH_LIBRARIES GTest::GTest GTest::Main) endif() endif() if(GTEST_INCLUDE_DIRS) include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) endif() message(STATUS "GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}") message(STATUS "GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}") # Try to find gmock if(NOT GMOCK_LIB AND TARGET GTest::gmock) set(GMOCK_LIB GTest::gmock) elseif(MSVC) # Explicitly specify that we consume GTest from shared library. The rest of # code logic below determines whether we link Release or Debug flavor of the # library. These flavors have different prefix on Windows, gmock and gmockd # respectively. add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) if(GMOCK_LIB) # unset GMOCK_LIB to force find_library to redo the lookup, as the cached # entry could cause linking to incorrect flavor of gmock and leading to # runtime error. unset(GMOCK_LIB CACHE) endif() endif() if(NOT GMOCK_LIB) if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib) else() find_library(GMOCK_LIB gmock PATH_SUFFIXES lib) endif() # Reset GMOCK_LIB if it was not found, or some target may link # GMOCK_LIB-NOTFOUND if(NOT GMOCK_LIB) unset(GMOCK_LIB) unset(GMOCK_LIB CACHE) endif() endif() enable_testing() if(WITH_BENCHMARK) # Benchmark respects the CMAKE_PREFIX_PATH find_package(benchmark CONFIG REQUIRED) endif() endif() include(CMakePackageConfigHelpers) if(DEFINED OPENTELEMETRY_BUILD_DLL) if(NOT WIN32) message(FATAL_ERROR "Build DLL is only supported on Windows!") endif() if(NOT MSVC) message(WARNING "Build DLL is supposed to work with MSVC!") endif() if(WITH_STL) message( WARNING "Build DLL with C++ STL could cause binary incompatibility!") endif() add_definitions(-DOPENTELEMETRY_BUILD_EXPORT_DLL) endif() include_directories(api/include) add_subdirectory(api) if(WITH_OPENTRACING) find_package(OpenTracing CONFIG QUIET) if(NOT OpenTracing_FOUND) set(OPENTRACING_DIR "third_party/opentracing-cpp") message(STATUS "Trying to use local ${OPENTRACING_DIR} from submodule") if(EXISTS "${PROJECT_SOURCE_DIR}/${OPENTRACING_DIR}/.git") set(SAVED_BUILD_TESTING ${BUILD_TESTING}) set(BUILD_TESTING OFF) set(SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "") add_subdirectory(${OPENTRACING_DIR}) set(BUILD_TESTING ${SAVED_BUILD_TESTING}) set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${SAVED_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}) else() message( FATAL_ERROR "\nopentracing-cpp package was not found. Please either provide it manually or clone with submodules. " "To initialize, fetch and checkout any nested submodules, you can use the following command:\n" "git submodule update --init --recursive") endif() else() message(STATUS "Using external opentracing-cpp") endif() add_subdirectory(opentracing-shim) endif() if(NOT WITH_API_ONLY) set(BUILD_TESTING ${BUILD_TESTING}) include_directories(sdk/include) include_directories(sdk) include_directories(ext/include) add_subdirectory(sdk) add_subdirectory(ext) add_subdirectory(exporters) if(BUILD_TESTING) add_subdirectory(test_common) endif() if(WITH_EXAMPLES) add_subdirectory(examples) endif() if(WITH_FUNC_TESTS) add_subdirectory(functional) endif() endif() include(cmake/opentelemetry-build-external-component.cmake) include(cmake/patch-imported-config.cmake) if(OPENTELEMETRY_INSTALL) # Export cmake config and support find_packages(opentelemetry-cpp CONFIG) # Write config file for find_packages(opentelemetry-cpp CONFIG) set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") configure_package_config_file( "${CMAKE_CURRENT_LIST_DIR}/cmake/opentelemetry-cpp-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" PATH_VARS OPENTELEMETRY_ABI_VERSION_NO OPENTELEMETRY_VERSION PROJECT_NAME INCLUDE_INSTALL_DIR CMAKE_INSTALL_LIBDIR NO_CHECK_REQUIRED_COMPONENTS_MACRO) # Write version file for find_packages(opentelemetry-cpp CONFIG) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake" VERSION ${OPENTELEMETRY_VERSION} COMPATIBILITY ExactVersion) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") # Export all components export( EXPORT "${PROJECT_NAME}-target" NAMESPACE "${PROJECT_NAME}::" FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}-target.cmake" ) install( EXPORT "${PROJECT_NAME}-target" NAMESPACE "${PROJECT_NAME}::" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") if(BUILD_PACKAGE) include(cmake/package.cmake) include(CPack) endif() endif() opentelemetry-cpp-1.19.0/CMakeSettings.json000066400000000000000000000060041474412371400206610ustar00rootroot00000000000000{ "configurations": [ { "name": "nostd-x64-Debug", "generator": "Ninja", "configurationType": "Debug", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${projectDir}\\out\\vs2019\\${name}", "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "variables": [ { "name": "WITH_OTLP_GRPC", "value": "True", "type": "BOOL" }, { "name": "WITH_EXAMPLES", "value": "true", "type": "BOOL" } ] }, { "name": "nostd-x64-Release", "generator": "Ninja", "configurationType": "Release", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${projectDir}\\out\\vs2019\\${name}", "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "cmakeToolchain": "", "variables": [ { "name": "WITH_OTLP_GRPC", "value": "True", "type": "BOOL" }, { "name": "WITH_EXAMPLES", "value": "true", "type": "BOOL" } ] }, { "name": "stdlib-x64-Debug", "generator": "Ninja", "configurationType": "Debug", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${projectDir}\\out\\vs2019\\${name}", "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "variables": [ { "name": "WITH_STL", "value": "True", "type": "BOOL" }, { "name": "WITH_OTLP_GRPC", "value": "True", "type": "BOOL" }, { "name": "WITH_EXAMPLES", "value": "true", "type": "BOOL" }, { "name": "WITH_PROMETHEUS", "value": "True", "type": "BOOL" } ] }, { "name": "stdlib-x64-Release", "generator": "Ninja", "configurationType": "Release", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${projectDir}\\out\\vs2019\\${name}", "installRoot": "${projectDir}\\out\\vs2019\\${name}\\install", "cmakeCommandArgs": "", "buildCommandArgs": "", "ctestCommandArgs": "", "cmakeToolchain": "", "variables": [ { "name": "WITH_STL", "value": "True", "type": "BOOL" }, { "name": "WITH_OTLP_GRPC", "value": "True", "type": "BOOL" }, { "name": "WITH_EXAMPLES", "value": "true", "type": "BOOL" }, { "name": "WITH_PROMETHEUS", "value": "True", "type": "BOOL" } ] } ] } opentelemetry-cpp-1.19.0/CODE_OF_CONDUCT.md000066400000000000000000000002401474412371400200600ustar00rootroot00000000000000# OpenTelemetry Community Code of Conduct OpenTelemetry follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). opentelemetry-cpp-1.19.0/CONTRIBUTING.md000066400000000000000000000243501474412371400175220ustar00rootroot00000000000000# Contributing to opentelemetry-cpp The OpenTelemetry C/C++ special interest group (SIG) meets regularly. See the OpenTelemetry [community](https://github.com/open-telemetry/community#cc-sdk) repo for information on this and other language SIGs. See the [public meeting notes](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hPLocw/edit) for a summary description of past meetings. To request edit access, join the meeting or get in touch on [Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ). See the [community membership document](https://github.com/open-telemetry/community/blob/main/community-membership.md) on how to become a [**Member**](https://github.com/open-telemetry/community/blob/main/community-membership.md#member), [**Approver**](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) and [**Maintainer**](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer). ## Development OpenTelemetry C++ uses the [Google naming convention](https://google.github.io/styleguide/cppguide.html#Naming). Code is formatted automatically and enforced by CI. ### Build and Run Code Examples Note: these instructions apply to examples configured with Bazel, see example-specific documentation for other build automation tools. Install the latest bazel version by following the steps listed [here](https://docs.bazel.build/versions/master/install.html). Select an example of interest from the [examples folder](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/examples). Inside each example directory is a `BUILD` file containing instructions for Bazel. Find the binary name of your example by inspecting the contents of this `BUILD` file. Build the example from the root of the opentelemetry-cpp directory using Bazel. Replace `` with the identifier found in the previous step: ```sh bazel build //examples/: ``` Run the resulting executable to see telemetry from the application as it calls the instrumented library: ```sh bazel-bin/examples// ``` For instance, building and running the `simple` example can be done as follows: ```sh bazel build //examples/simple:example_simple bazel-bin/examples/simple/example_simple ``` ### DevContainer Setup for Project This guide provides instructions on how to set up and use the development container (`devcontainer`) environment to streamline testing and development for this project. With the DevContainer, you can work in a consistent environment configured with all the necessary dependencies and tools. #### Prerequisites Before getting started, ensure you have the following installed: * **Docker**: DevContainers require Docker for containerization. * **Visual Studio Code (VSCode)** with the **Remote - Containers** extension. #### Getting Started * **Open the Project in DevContainer**: Open the project in VSCode. When prompted to "Reopen in Container," select this option. If you’re not prompted, you can manually open the container by selecting **Remote-Containers: Reopen in Container** from the command palette (`F1` or `Ctrl+Shift+P`). * **Container Setup**: The DevContainer environment will automatically build based on the configuration files provided (e.g., `.devcontainer/devcontainer.json`). This setup will install required dependencies, tools, and environment variables needed for the project. #### Available Commands Once inside the DevContainer, you can use the following commands to run tests and CI workflows. ##### 1. Run Tests with Bazelisk To run tests with Bazelisk using specific compilation options, use: ```bash bazelisk-linux-amd64 test --copt=-DENABLE_LOGS_PREVIEW --test_output=errors --cache_test_results=no --copt=-DENABLE_TEST //exporters/otlp/... ``` ###### Command Breakdown * `--copt=-DENABLE_LOGS_PREVIEW`: Enables preview logs. * `--test_output=errors`: Shows only the errors in the test output. * `--cache_test_results=no`: Forces Bazel to re-run tests without caching. * `--copt=-DENABLE_TEST`: Enables testing capabilities for the target code. * `//exporters/otlp/...`: Specifies the test target path. ##### 2. Run CI Script You can also run the CI script provided to perform testing with the following command as an example: ```bash bash ci/do_ci.sh cmake.exporter.otprotocol.test ``` This command initiates the CI pipeline, executing tests specifically for the **cmake.exporter.otprotocol** module. #### Troubleshooting If you encounter issues: * **Rebuild the DevContainer**: From the command palette, run **Remote-Containers: Rebuild Container** to reinitialize the environment. * **Check Bazelisk and CI Script Logs**: Inspect logs for any configuration or dependency issues. #### Additional Notes * You can adjust compiler options (`--copt`) as needed to test additional flags or enable/disable specific features. * The test results will be displayed in the terminal within the DevContainer for easy debugging. #### Resources * **Bazelisk Documentation**: [https://github.com/bazelbuild/bazelisk](https://github.com/bazelbuild/bazelisk) * **VSCode DevContainer Documentation**: [https://code.visualstudio.com/docs/remote/containers](https://code.visualstudio.com/docs/remote/containers) ## Pull Requests ### How to Send Pull Requests Everyone is welcome to contribute code to `opentelemetry-cpp` via GitHub pull requests (PRs). To create a new PR, fork the project in GitHub and clone the upstream repo: ```sh git clone --recursive https://github.com/open-telemetry/opentelemetry-cpp.git ``` Add your fork as a remote: ```sh git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-cpp.git ``` If you haven't, make sure you are loading the submodules required to build OpenTelemetry ```sh git submodule init git submodule update ``` The source code is automatically formatted using clang-format. The output can vary between versions, so make sure to install `clang-format` version `10.0`, and have `clang-format-10` in your execution path, so that the helper script `tools/format.sh` can find it. Check out a new branch, make modifications and push the branch to your fork: ```sh git checkout -b feature # edit files tools/format.sh git commit git push fork feature ``` If you made changes to the Markdown documents (`*.md` files), install the latest [`markdownlint-cli`](https://github.com/igorshubovych/markdownlint-cli) and run: ```sh markdownlint . ``` Open a pull request against the main `opentelemetry-cpp` repo. To run tests locally, please read the [CI instructions](ci/README.md). ### How to Receive Comments * If the PR is not ready for review, please put `[WIP]` in the title, tag it as `work-in-progress`, or mark it as [`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/). * Make sure [CLA](https://identity.linuxfoundation.org/projects/cncf) is signed and CI is clear. * For non-trivial changes, please update the [CHANGELOG](./CHANGELOG.md). ### How to Get PRs Merged A PR is considered to be **ready to merge** when: * It has received two approvals with at least one approval from [Approver](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) / [Maintainer](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer) (at different company). * A pull request opened by an Approver / Maintainer can be merged with only one approval from Approver / Maintainer (at different company). * Major feedback items/points are resolved. * It has been open for review for at least one working day. This gives people reasonable time to review. * Trivial changes (typo, cosmetic, doc, etc.) don't have to wait for one day. * Urgent fixes can take exceptions as long as it has been actively communicated. Any Maintainer can merge the PR once it is **ready to merge**. Maintainer can make conscious judgement to merge pull requests which have not strictly met above mentioned requirements. If a PR has been stuck (e.g. there are lots of debates and people couldn't agree on each other), the owner should try to get people aligned by: * Consolidating the perspectives and putting a summary in the PR. It is recommended to add a link into the PR description, which points to a comment with a summary in the PR conversation * Stepping back to see if it makes sense to narrow down the scope of the PR or split it up. If none of the above worked and the PR has been stuck for more than 2 weeks, the owner should bring it to the OpenTelemetry C++ SIG meeting. See [README.md](README.md#contributing) for the meeting link. ## Design Choices As with other OpenTelemetry clients, opentelemetry-cpp follows the [opentelemetry-specification](https://github.com/open-telemetry/opentelemetry-specification). It's especially valuable to read through the [library guidelines](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/library-guidelines.md). ## Useful Resources Hi! If you’re looking at this document, these resources will provide you the knowledge to get started as a newcomer to the OpenTelemetry project. They will help you understand the OpenTelemetry Project, its components, and specifically the C++ repository. ### Reading Resources * Medium [article](https://medium.com/opentelemetry/how-to-start-contributing-to-opentelemetry-b23991ad91f4) (October 2019) on how to start contributing to the OpenTelemetry project. * Medium [article](https://medium.com/opentelemetry/opentelemetry-beyond-getting-started-5ac43cd0fe26) (January 2020) describing the overarching goals and use cases for OpenTelemetry. ### Relevant Documentation * [OpenTelemetry Specification](https://github.com/open-telemetry/opentelemetry-specification) * The OpenTelemetry Specification describes the requirements and expectations of for all OpenTelemetry implementations. * Read through the OpenTelemetry C++ documentation * The [API](https://opentelemetry-cpp.readthedocs.io/en/latest/api/api.html) and [SDK](https://opentelemetry-cpp.readthedocs.io/en/latest/sdk/sdk.html) documentation provides a lot of information on what the classes and their functions are used for. Please contribute! You’re welcome to add more information if you come across any helpful resources. opentelemetry-cpp-1.19.0/DEPRECATED.md000066400000000000000000000056301474412371400172130ustar00rootroot00000000000000# Deprecated This document lists all the items currently deprecated in opentelemetry-cpp. Deprecated items will be removed in the future. ## Guidelines ### Maintainer guidelines See the [deprecation-process](./docs/deprecation-process.md) ## [TEMPLATE] ### New Deprecation Title (Template) #### Announcement (Template) #### Motivation (Template) #### Scope (Template) #### Mitigation (Template) #### Planned removal (Template) ## [Platforms] N/A ## [Compilers] N/A ## [Third party dependencies] N/A ## [Build tools] N/A ## [Build scripts] N/A ## [opentelemetry-cpp API] N/A ## [opentelemetry-cpp SDK] N/A ## [opentelemetry-cpp Exporter] N/A ## [Documentation] N/A ## Semantic conventions ### Header files "semantic_conventions.h" #### Announcement (semantic_conventions.h) Deprecation is announced as part of the migration to weaver: * `Version:` release following opentelemetry-cpp 1.17.0 * `Date:` Nov 9, 2024 * `PR:` [PR 3105](https://github.com/open-telemetry/opentelemetry-cpp/pull/3105) #### Motivation (semantic_conventions.h) The header files for semantic conventions are generated automatically. The tooling to generate these files is changing: * before, the build-tool repository was used * now, the weaver repository is used Changes in tooling allows to generate code that is better organized, with dedicated header files per group of semantic conventions, instead of a single header file for everything. #### Scope (semantic_conventions.h) The following files: * `api/include/opentelemetry/trace/semantic_conventions.h` * `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` are now deprecated. They correspond to semantic conventions v1.27.0, and will no longer be maintained up to date. These files will be removed in the future. #### Mitigation (semantic_conventions.h) Two things have changed: * the header file to use * the symbol name to use. Before, the semantic convention for `url.full` was: * declared in file `semantic_conventions.h` * declared as symbol `SemanticConventions::kUrlFull` Now, the `url.full` convention, which is part or the `url` group, is: * declared in file `semconv/url_attributes.h` * declared as symbol `semconv::url::kUrlFull` Application code that uses semantic conventions must be adjusted accordingly. In addition, semantic conventions that are not marked as stable are generated in a different header file, placed under directory `incubating`, to better separate stable and non stable code. For example, file `semconv/incubating/url_attributes.h` defines `semconv::url::kUrlDomain`, which is not marked as stable in semconv v1.27.0 #### Planned removal (semantic_conventions.h) The following files: * `api/include/opentelemetry/trace/semantic_conventions.h` * `sdk/include/opentelemetry/sdk/resource/semantic_conventions.h` will be removed. The removal date is planned for July 1, 2025. This allows more than six months for applications to adjust. opentelemetry-cpp-1.19.0/INSTALL.md000066400000000000000000000275551474412371400167330ustar00rootroot00000000000000# Building opentelemetry-cpp [CMake](https://cmake.org/) and [Bazel](https://bazel.build) are the official build systems for opentelemetry-cpp. ## Dependencies You can link OpenTelemetry C++ SDK with libraries provided in [dependencies.md](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/dependencies.md) (complete list of libraries with versions used in our CI can be found [here](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release)). ## Build instructions using CMake ### Prerequisites for CMake build - A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms Supported](./README.md#supported-development-platforms) for more information. - A compatible C++ compiler supporting at least C++14. Major compilers are supported. Refer to [Supported Compilers](./README.md#supported-c-versions) for more information. - [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from repository. To install Git, consult the [Set up Git](https://help.github.com/articles/set-up-git/) guide on GitHub. - [CMake](https://cmake.org/) for building opentelemetry-cpp API, SDK with their unittests. We use CMake version 3.15.2 in our build system. To install CMake, consult the [Installing CMake](https://cmake.org/install/) guide. - [GoogleTest](https://github.com/google/googletest) framework to build and run the unittests. Refer to [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L5) for version of GoogleTest used in CI. To install GoogleTest, consult the [GoogleTest Build Instructions](https://github.com/google/googletest/blob/master/googletest/README.md#generic-build-instructions). - [Google Benchmark](https://github.com/google/benchmark) framework to build and run benchmark tests. Refer to [third_party_release](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/third_party_release#L4) for version of Benchmark used in CI. To install Benchmark, consult the [GoogleBenchmark Build Instructions](https://github.com/google/benchmark#installation). - Apart from above core requirements, the Exporters and Propagators have their build dependencies which are not covered here. E.g, the OTLP Exporter needs grpc/protobuf library, the Zipkin exporter needs nlohmann-json and libcurl, the ETW exporter needs nlohmann-json to build. This is covered in the build instructions for each of these components. ### Building as standalone CMake Project 1. Getting the opentelemetry-cpp source with its submodules: ```console # Change to the directory where you want to create the code repository $ cd ~ $ mkdir source && cd source && git clone --recurse-submodules https://github.com/open-telemetry/opentelemetry-cpp Cloning into 'opentelemetry-cpp'... ... Resolving deltas: 100% (3225/3225), done. $ ``` 2. Navigate to the repository cloned above, and create the `CMake` build configuration. ```console $ cd opentelemetry-cpp $ mkdir build && cd build && cmake .. -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is GNU 9.3.0 ... -- Configuring done -- Generating done -- Build files have been written to: /home//source/opentelemetry-cpp/build $ ``` Some of the available cmake build variables we can use during cmake configuration: - `-DCMAKE_POSITION_INDEPENDENT_CODE=ON` : Please note that with default configuration, the code is compiled without `-fpic` option, so it is not suitable for inclusion in shared libraries. To enable the code for inclusion in shared libraries, this variable is used. - `-DBUILD_SHARED_LIBS=ON` : To build shared libraries for the targets. Please refer to note [below](#building-shared-libs-for-windows) for Windows DLL support. - `-DWITH_OTLP_GRPC=ON` : To enable building OTLP GRPC exporter. - `-DWITH_OTLP_HTTP=ON` : To enable building OTLP HTTP exporter. - `-DWITH_PROMETHEUS=ON` : To enable building prometheus exporter. - `-DOPENTELEMETRY_INSTALL=ON`: To install `otel-cpp` library needed for external code linking. 3. Once the build configuration is created, build the CMake targets - this includes building SDKs and unittests for API and SDK. Note that since API is header only library, no separate build is triggered for it. ```console $ cmake --build . --target all Scanning dependencies of target timestamp_test [ 0%] Building CXX object api/test/core/CMakeFiles/timestamp_test.dir/timestamp_test.cc.o [ 1%] Linking CXX executable timestamp_test ... Scanning dependencies of target w3c_tracecontext_test [ 99%] Building CXX object ext/test/w3c_tracecontext_test/CMakeFiles/w3c_tracecontext_test.dir/main.cc.o [100%] Linking CXX executable w3c_tracecontext_test [100%] Built target w3c_tracecontext_test $ ``` 4. Once CMake tests are built, run them with `ctest` command ```console $ ctest Test project /tmp/opentelemetry-cpp/build Start 1: trace.SystemTimestampTest.Construction ... Start 380: ext.http.urlparser.UrlParserTests.BasicTests ... 100% tests passed, 0 tests failed out of 380 $ ``` 5. Optionally install the header files for API, and generated targets and header files for SDK at custom/default install location. ```console $ cmake --install . --prefix // -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config.cmake -- Installing: //lib/cmake/opentelemetry-cpp/opentelemetry-cpp-config-version.cmake ... $ ``` ### Incorporating into an existing CMake Project To use the library from a CMake project, you can locate it directly with `find_package` and use the imported targets from generated package configurations. As of now, this will import targets for both API and SDK. In future, there may be separate packages for API and SDK which can be installed and imported separately according to need. ```cmake # CMakeLists.txt find_package(opentelemetry-cpp CONFIG REQUIRED) ... target_include_directories(foo PRIVATE ${OPENTELEMETRY_CPP_INCLUDE_DIRS}) target_link_libraries(foo PRIVATE ${OPENTELEMETRY_CPP_LIBRARIES}) ``` ## Build instructions using Bazel NOTE: Experimental, and not supported for all the components. Make sure the [GoogleTest](https://github.com/google/googletest) installation may fail if there is a different version of googletest already installed in system-defined path. ### Prerequisites for Bazel build - A supported platform (e.g. Windows, macOS or Linux). Refer to [Platforms Supported](./README.md#supported-development-platforms) for more information. - A compatible C++ compiler supporting at least C++14. Major compilers are supported. Refer to [Supported Compilers](./README.md#supported-c-versions) for more information. - [Git](https://git-scm.com/) for fetching opentelemetry-cpp source code from repository. To install Git, consult the [Set up Git](https://help.github.com/articles/set-up-git/) guide on GitHub. - [Bazel](https://www.bazel.build/) for building opentelemetry-cpp API, SDK with their unittests. We use 3.7.2 in our build system. To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide. ### Building as standalone Bazel Project 1. Getting the opentelemetry-cpp source: ```console # Change to the directory where you want to create the code repository $ cd ~ $ mkdir source && cd source $ git clone https://github.com/open-telemetry/opentelemetry-cpp Cloning into 'opentelemetry-cpp'... ... Resolving deltas: 100% (3225/3225), done. $ ``` 2. Navigate to the repository cloned above, download the dependencies and build the source code: ```console $ cd opentelemetry-cpp $ bazel build //... bazel build -- //... -//exporters/otlp/... -//exporters/prometheus/... Extracting Bazel installation... Starting local Bazel server and connecting to it... INFO: Analyzed 121 targets (98 packages loaded, 3815 targets configured). INFO: Found 121 targets... INFO: From Compiling sdk/src/trace/tracer_context.cc: ... ``` 3. Once Bazel tests are built, run them with `bazel test //...` command ```console $ bazel test //... .. $ ``` 4. The build artifacts will be located under `bazel-bin` ### Incorporating into an existing Bazel Project - WORKSPACE file: ```console http_archive( name = "io_opentelemetry_cpp", sha256 = "", strip_prefix = "opentelemetry-cpp-1.0.1", urls = [ "https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz" ], ) # Load OpenTelemetry dependencies after load. load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps") opentelemetry_cpp_deps() # (required after v1.8.0) Load extra dependencies required for OpenTelemetry load("@io_opentelemetry_cpp//bazel:extra_deps.bzl", "opentelemetry_extra_deps") opentelemetry_extra_deps() # Load gRPC dependencies after load. load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") grpc_deps() # Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") grpc_extra_deps() ``` - Component level BUILD file: ```console cc_library( name = "" ... deps = [ "@io_opentelemetry_cpp//api", "@io_opentelemetry_cpp//exporters/otlp:otlp_exporter", "@io_opentelemetry_cpp//sdk/src/trace", ... ], ... ) ``` ## Building shared libs for Windows Windows DLL build is supported under **preview**. Please check the [doc](./docs/build-as-dll.md) for more details. ## Generating binary packages OpenTelemetry C++ supports generating platform specific binary packages from CMake configuration. The packages generated through this mayn't be production ready, and user may have to customize it further before using it as distribution. - Linux : deb, rpm, tgz - MacOS : tgz - Windows : NuGet, zip This requires platform specific package generators already installed. The package generation can subsequently be enabled by using BUILD_PACKAGE option during cmake configuration ```console $ cd opentelemetry-cpp $ mkdir build && cd build && cmake -DBUILD_PACKAGE=ON .. -- Package name: opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb -- Configuring done -- Generating done ... $ ``` Once build is complete as specified in [standalone build section](#building-as-standalone-cmake-project), the package can be generated as below. ```console $ cpack -C debug CPack: Create package using DEB ... CPack: - package: /home//opentelemetry-cpp/build/opentelemetry-cpp-1.8.1-ubuntu-20.04-x86_64.deb generated. $ ``` ## Using Package Managers If you are using [Conan](https://www.conan.io/) to manage your dependencies, add [`opentelemetry-cpp/x.y.z`](https://conan.io/center/opentelemetry-cpp) to your `conanfile`'s requires, where `x.y.z` is the release version you want to use. Please file issues [here](https://github.com/conan-io/conan-center-index/issues) if you experience problems with the packages. If you are using [vcpkg](https://github.com/Microsoft/vcpkg/) on your project for external dependencies, then you can install the [opentelemetry-cpp package](https://github.com/microsoft/vcpkg/tree/master/ports/opentelemetry-cpp) with `vcpkg install opentelemetry-cpp` and follow the then displayed descriptions. Please see the vcpkg project for any issues regarding the packaging. If you are using [alpine linux](https://www.alpinelinux.org/) you can install the [opentelemetry-cpp packages](https://pkgs.alpinelinux.org/packages?name=opentelemetry-cpp-*) with `apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing opentelemetry-cpp-dev`. Please note, these packages are not officially provided and maintained by OpenTelemetry C++ project, and are just listed here to consolidate all such efforts for ease of developers. opentelemetry-cpp-1.19.0/LICENSE000066400000000000000000000261351474412371400163010ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. opentelemetry-cpp-1.19.0/MODULE.bazel000066400000000000000000000025051474412371400172730ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 module( name = "opentelemetry-cpp", version = "1.17.0", compatibility_level = 0, repo_name = "io_opentelemetry_cpp", ) bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") bazel_dep(name = "bazel_skylib", version = "1.5.0") bazel_dep(name = "curl", version = "8.8.0") bazel_dep(name = "grpc", version = "1.63.1.bcr.1", repo_name = "com_github_grpc_grpc") bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "github_nlohmann_json") bazel_dep(name = "opentelemetry-proto", version = "1.5.0", repo_name = "com_github_opentelemetry_proto") bazel_dep(name = "opentracing-cpp", version = "1.6.0", repo_name = "com_github_opentracing") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "prometheus-cpp", version = "1.3.0", repo_name = "com_github_jupp0r_prometheus_cpp") bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") bazel_dep(name = "zlib", version = "1.3.1.bcr.1") bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark") bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") opentelemetry-cpp-1.19.0/README.md000066400000000000000000000124771474412371400165570ustar00rootroot00000000000000# OpenTelemetry C++ [![Slack](https://img.shields.io/badge/slack-@cncf/otel/cpp-brightgreen.svg?logo=slack)](https://cloud-native.slack.com/archives/C01N3AT62SJ) [![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-cpp/branch/main/graphs/badge.svg?)](https://codecov.io/gh/open-telemetry/opentelemetry-cpp/) [![Build Status](https://github.com/open-telemetry/opentelemetry-cpp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/open-telemetry/opentelemetry-cpp/actions) [![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-cpp?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-cpp/releases/) The C++ [OpenTelemetry](https://opentelemetry.io/) client. ## Project Status **Stable** across all 3 signals i.e. `Logs`, `Metrics`, and `Traces`. See [Spec Compliance Matrix](https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md) to understand which portions of the specification has been implemented in this repo. ## Supported C++ Versions Code shipped from this repository generally supports the following versions of C++ standards: * ISO/IEC 14882:2014 (C++14) * ISO/IEC 14882:2017 (C++17) * ISO/IEC 14882:2020 (C++20) Any exceptions to this are noted in the individual `README.md` files. Please note that supporting the [C Programming Language](https://en.wikipedia.org/wiki/C_(programming_language)) is not a goal of the current project. ## Supported Development Platforms Our CI pipeline builds and tests on following `x86-64` platforms: | Platform | Build type | |---------------------------------------------------------------------|---------------| | ubuntu-22.04 (GCC 10, GCC 12, Clang 14) | CMake, Bazel | | ubuntu-20.04 (GCC 9.4.0 - default compiler) | CMake, Bazel | | ubuntu-20.04 (GCC 9.4.0 with -std=c++14/17/20 flags) | CMake, Bazel | | macOS 12.7 (Xcode 14.2) | Bazel | | Windows Server 2019 (Visual Studio Enterprise 2019) | CMake, Bazel | | Windows Server 2022 (Visual Studio Enterprise 2022) | CMake | In general, the code shipped from this repository should build on all platforms having C++ compiler with [supported C++ standards](#supported-c-versions). ## Dependencies Please refer to [Dependencies.md](docs/dependencies.md) for OSS Dependencies and license requirements. ## Installation Please refer to [INSTALL.md](./INSTALL.md). ## Getting Started As an application owner or the library author, you can find the getting started guide and reference documentation on [opentelemetry-cpp.readthedocs.io](https://opentelemetry-cpp.readthedocs.io/en/latest/) The `examples/simple` directory contains a minimal program demonstrating how to instrument a small library using a simple `processor` and console `exporter`, along with build files for CMake and Bazel. ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) We meet weekly, and the time of the meeting alternates between Monday at 13:00 PT and Wednesday at 9:00 PT. The meeting is subject to change depending on contributors' availability. Check the [OpenTelemetry community calendar](https://github.com/open-telemetry/community#calendar) for specific dates and Zoom meeting links. Meeting notes are available as a public [Google doc](https://docs.google.com/document/d/1i1E4-_y4uJ083lCutKGDhkpi3n4_e774SBLi9hPLocw/edit?usp=sharing). For edit access, get in touch on [Slack](https://cloud-native.slack.com/archives/C01N3AT62SJ). [Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer) ([@open-telemetry/cpp-maintainers](https://github.com/orgs/open-telemetry/teams/cpp-maintainers)): * [Ehsan Saei](https://github.com/esigo) * [Lalit Kumar Bhasin](https://github.com/lalitb), Microsoft * [Marc Alff](https://github.com/marcalff), Oracle * [Tom Tan](https://github.com/ThomsonTan), Microsoft [Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver) ([@open-telemetry/cpp-approvers](https://github.com/orgs/open-telemetry/teams/cpp-approvers)): * [Josh Suereth](https://github.com/jsuereth), Google * [WenTao Ou](https://github.com/owent), Tencent [Emeritus Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/main/community-membership.md#emeritus-maintainerapprovertriager): * [Alolita Sharma](https://github.com/alolita) * [Emil Mikulic](https://github.com/g-easy) * [Jodee Varney](https://github.com/jodeev) * [Johannes Tax](https://github.com/pyohannes) * [Max Golovanov](https://github.com/maxgolov) * [Reiley Yang](https://github.com/reyang) * [Ryan Burn](https://github.com/rnburn) ### Thanks to all the people who have contributed [![contributors](https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-cpp)](https://github.com/open-telemetry/opentelemetry-cpp/graphs/contributors) ## Release Schedule See the [release notes](https://github.com/open-telemetry/opentelemetry-cpp/releases) for existing releases. See the [project milestones](https://github.com/open-telemetry/opentelemetry-cpp/milestones) for details on upcoming releases. The dates and features described in issues and milestones are estimates, and subject to change. opentelemetry-cpp-1.19.0/RELEASING.md000066400000000000000000000045031474412371400171220ustar00rootroot00000000000000# Release Process ## Pre Release 1: Upgrade to latest [dependencies](docs/maintaining-dependencies.md) if required. 2: Make sure all relevant changes for this release are included under `Unreleased` section in `CHANGELOG.md` and are in language that non-contributors to the project can understand. 3: Run the pre-release script. It creates a branch `pre_release_` and updates `CHANGELOG.md` with the ``: ```sh ./buildscripts/pre_release.sh -t ``` 4: Verify that CHANGELOG.md is updated properly: ```sh git diff main ``` 5: Push the changes to upstream and create a Pull Request on GitHub. Be sure to include the curated changes from the [Changelog](./CHANGELOG.md) in the description. ## Tag Once the above Pull Request has been approved and merged it is time to tag the merged commit. ***IMPORTANT***: It is critical you use the same tag that you used in the Pre-Release step! Failure to do so will leave things in a broken state. 1: Note down the commit hash of the master branch after above PR request is merged: `` ```sh git show -s --format=%H ``` 2: Create a github tag on this commit hash: ```sh git tag -a "" -s -m "Version " "" ``` 3: Push tag to upstream remote ```sh git push upstream ``` ## Versioning Once tag is created, it's time to use that tag for Runtime Versioning 1: Create a new brach for updating version information in `./sdk/src/version.cc`. ```sh git checkout -b update_version_${tag} master ``` 2: Run the pre-commit script to update the version: ```sh ./buildscripts/pre-commit ``` 3: Check if any changes made since last release broke ABI compatibility. If yes, update `OPENTELEMETRY_ABI_VERSION_NO` in [version.h](api/include/opentelemetry/version.h). 4: Push the changes to upstream and create a Pull Request on GitHub. 5: Once changes are merged, move the tag created earlier to the new commit hash from step 4. ```sh git tag -f git push --tags --force ``` ## Release Finally create a Release for the new `` on GitHub. The release body should include all the release notes from the Changelog for this release. ## Post Release Update the OpenTelemetry.io document [here](https://github.com/open-telemetry/opentelemetry.io/tree/main/content/en/docs/instrumentation/cpp) by sending a Pull Request. opentelemetry-cpp-1.19.0/Versioning.md000066400000000000000000000114571474412371400177420ustar00rootroot00000000000000# Versioning This document describes the versioning policy for this repository. ## Goals ### API and SDK Compatibility Once the API for a given signal (spans, logs, metrics, baggage) has been officially released, that API module will function with any SDK that has the same MAJOR version and equal or greater MINOR or PATCH version. For example, application compiled with API v1.1 is compatible with SDK v1.1.2, v1.2.0, etc. For example, libraries that are instrumented with `opentelemetry 1.0.1` will function in applications using `opentelemetry 1.11.33` or `opentelemetry 1.3.4`, buy may not work in applications using `opentelemetry 2.0.0`. ### ABI Stability Refer to the [ABI Policy](./docs/abi-policy.md) for more details. To summarise: * The API is header only, and uses ABI compliant interfaces. However, ABI stability is not guaranteed for SDK. * In case of ABI breaking changes, a new `inline namespace` version will be introduced, and the existing linked applications can continue using the older version unless they relink with newer version. ## Release Policy * Release versions will follow [SemVer 2.0](https://semver.org/). * Only a single source package containing the API, SDK, and exporters which are required by the specification would be released. All these components are always versioned and released together. For example, any changes in one of the exporter would result in version update of the entire source package even though there is no changes in API, SDK and other exporters. * Experimental releases: New (unstable) telemetry signals and features will be introduced behind feature flag protected by a preprocessor macro. ```cpp #ifdef FEATURE_FLAG #endif ``` As we deliver the package in source form, and the user is responsible to build it for their platform, the user must be aware of these feature flags (documented in the [CHANGELOG.md](CHANGELOG.md) file). The user must enable them explicitly through their build system (CMake, Bazel or others) to use any preview features. The guidelines in creating feature flag would be: * Naming: * `ENABLE__PREVIEW` : For experimental release of signal api/sdks eg, `METRICS_PREVIEW`, `LOGS_PREVIEW`, * `ENABLE___PREVIEW` : For experimental release for any feature within stable signal. For example, `TRACING_JAEGER_PREVIEW` to release the experimental Jaeger exporter for tracing. * Cleanup: It is good practice to keep feature-flags as shortlived as possible. And, also important to keep the number of them low. They should be used such that it is easy to remove/cleanup them once the experimental feature is stable. * New signals will be stabilized via a **minor version bump**, and are not allowed to break existing stable interfaces. Feature flags will be removed once we have a stable implementation for the signal. * As an exception, small experimental features in otherwise stable signals/components mayn't necessarily be released under feature flag. These would be flagged as experimental by adding a `NOTE` in it's header file - either at the beginning of file, or as the comment for the experimental API methods. Also, if the complete header is experimental, it would be prefixed as `experimental_`. As an example, the semantic conventions for trace signal is experimental at the time of the writing and is within `experimental_semantic_conventions.h` * Code under the "*::detail" namespace implements internal details, and is NOT part of public interface. Also, any API not documented in the [public documentation](https://opentelemetry-cpp.readthedocs.io/en/latest/) is NOT part of the public interface. * GitHub releases will be made for all released versions. ## Example Versioning Lifecycle Purely for illustration purposes, not intended to represent actual releases: * v0.0.1 release: * Contains experimental API and SDK of trace (without feature flag) * No API and SDK of logging and metrics available * v1.0.0-rc1 release: * Pre-release, no API/ABI guarantees, but more stable than alpha/beta. * Contains pre-release API and SDK of trace, baggage and resource * experimental metrics and logging API/SDK behind feature flag * v1.0.0: ( with traces ) * Contains stable API and SDK of trace, baggage and resource * experimental metrics and logging API/SDK behind feature flag * v1.5.0 release (with metrics) * Contains stable API and SDK of metrics, trace, baggage, resource. * experimental logging API/SDK behind feature flag * v1.10.0 release (with logging) * Contains stable API and SDK of logging, metrics, trace, baggage, resource. ### Before moving to version 1.0.0 * Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable. opentelemetry-cpp-1.19.0/WORKSPACE000066400000000000000000000011451474412371400165470ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 workspace(name = "io_opentelemetry_cpp") # Load our direct dependencies. load("//bazel:repository.bzl", "opentelemetry_cpp_deps") opentelemetry_cpp_deps() load("//bazel:extra_deps.bzl", "opentelemetry_extra_deps") opentelemetry_extra_deps() # Load gRPC dependencies after load. load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") grpc_deps() # Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511 load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") grpc_extra_deps() opentelemetry-cpp-1.19.0/WORKSPACE.bzlmod000066400000000000000000000002001474412371400200240ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 # Disables the default WORKSPACE when using bzlmod opentelemetry-cpp-1.19.0/api/000077500000000000000000000000001474412371400160365ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/BUILD000066400000000000000000000044641474412371400166300ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag") package(default_visibility = ["//visibility:public"]) CPP_STDLIBS = [ "none", "best", "2014", "2017", "2020", "2023", ] string_flag( name = "with_cxx_stdlib", build_setting_default = "best", values = CPP_STDLIBS, ) cc_library( name = "api", hdrs = glob(["include/**/*.h"]), defines = ["HAVE_ABSEIL"] + select({ ":set_cxx_stdlib_none": [], ### automatic selection ":set_cxx_stdlib_best": ["OPENTELEMETRY_STL_VERSION=(__cplusplus/100)"], # See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus ":set_cxx_stdlib_best_and_msvc": ["OPENTELEMETRY_STL_VERSION=(_MSVC_LANG/100)"], ### manual selection ":set_cxx_stdlib_2014": ["OPENTELEMETRY_STL_VERSION=2014"], ":set_cxx_stdlib_2017": ["OPENTELEMETRY_STL_VERSION=2017"], ":set_cxx_stdlib_2020": ["OPENTELEMETRY_STL_VERSION=2020"], ":set_cxx_stdlib_2023": ["OPENTELEMETRY_STL_VERSION=2023"], "//conditions:default": [], }) + select({ ":abi_version_no_1": ["OPENTELEMETRY_ABI_VERSION_NO=1"], ":abi_version_no_2": ["OPENTELEMETRY_ABI_VERSION_NO=2"], }), strip_include_prefix = "include", tags = ["api"], deps = [ "@com_google_absl//absl/base", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:variant", ], ) [config_setting( name = "set_cxx_stdlib_%s" % v, flag_values = {":with_cxx_stdlib": v}, ) for v in CPP_STDLIBS] config_setting( name = "set_cxx_stdlib_best_and_msvc", constraint_values = ["@bazel_tools//tools/cpp:msvc"], flag_values = {":with_cxx_stdlib": "best"}, ) bool_flag( name = "with_abseil", build_setting_default = False, deprecation = "The value of this flag is ignored. Bazel builds always depend on Abseil for its pre-adopted `std::` types. You should remove this flag from your build command.", ) int_flag( name = "abi_version_no", build_setting_default = 1, ) config_setting( name = "abi_version_no_1", flag_values = {":abi_version_no": "1"}, ) config_setting( name = "abi_version_no_2", flag_values = {":abi_version_no": "2"}, ) opentelemetry-cpp-1.19.0/api/CMakeLists.txt000066400000000000000000000113441474412371400206010ustar00rootroot00000000000000# Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 add_library(opentelemetry_api INTERFACE) target_include_directories( opentelemetry_api INTERFACE "$" "$") set_target_properties(opentelemetry_api PROPERTIES EXPORT_NAME api) if(OPENTELEMETRY_INSTALL) install( TARGETS opentelemetry_api EXPORT "${PROJECT_NAME}-target" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install( DIRECTORY include/opentelemetry DESTINATION include FILES_MATCHING PATTERN "*.h") unset(TARGET_DEPS) endif() if(BUILD_TESTING) add_subdirectory(test) endif() if(WITH_NO_DEPRECATED_CODE) target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_NO_DEPRECATED_CODE) endif() if(WITH_ABSEIL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL) target_link_libraries( opentelemetry_api INTERFACE absl::bad_variant_access absl::any absl::base absl::bits absl::city) list( APPEND TARGET_DEPS "absl_bad_variant_access" "absl_any" "absl_base" "absl_bits" "absl_city") endif() if(WITH_STL STREQUAL "OFF") message(STATUS "Building WITH_STL=OFF") elseif(WITH_STL STREQUAL "CXX11") message(STATUS "Building WITH_STL=CXX11") target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2011) elseif(WITH_STL STREQUAL "CXX14") message(STATUS "Building WITH_STL=CXX14") target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2014) elseif(WITH_STL STREQUAL "CXX17") message(STATUS "Building WITH_STL=CXX17") target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2017) elseif(WITH_STL STREQUAL "CXX20") message(STATUS "Building WITH_STL=CXX20") target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2020) elseif(WITH_STL STREQUAL "CXX23") message(STATUS "Building WITH_STL=CXX23") target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2023) elseif(WITH_STL STREQUAL "ON") message(STATUS "Building WITH_STL=ON") # "ON" corresponds to "CXX23" at this time. target_compile_definitions(opentelemetry_api INTERFACE OPENTELEMETRY_STL_VERSION=2023) else() message( FATAL_ERROR "WITH_STL must be ON, OFF, CXX11, CXX14, CXX17, CXX20 or CXX23") endif() if(WITH_GSL) target_compile_definitions(opentelemetry_api INTERFACE HAVE_GSL) # Guidelines Support Library path. Used if we are not on not get C++20. # find_package(Microsoft.GSL QUIET) if(TARGET Microsoft.GSL::GSL) target_link_libraries(opentelemetry_api INTERFACE Microsoft.GSL::GSL) list(APPEND TARGET_DEPS "gsl") else() set(GSL_DIR third_party/ms-gsl) target_include_directories( opentelemetry_api INTERFACE "$") endif() endif() if(WITH_NO_GETENV) target_compile_definitions(opentelemetry_api INTERFACE NO_GETENV) endif() if(WIN32) if(WITH_ETW) target_compile_definitions(opentelemetry_api INTERFACE HAVE_MSGPACK) endif() endif() if(WITH_ASYNC_EXPORT_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_ASYNC_EXPORT) endif() target_compile_definitions( opentelemetry_api INTERFACE OPENTELEMETRY_ABI_VERSION_NO=${OPENTELEMETRY_ABI_VERSION_NO}) if(WITH_OTLP_RETRY_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_OTLP_RETRY_PREVIEW) endif() if(WITH_OTLP_GRPC_SSL_MTLS_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_OTLP_GRPC_SSL_MTLS_PREVIEW) endif() if(WITH_METRICS_EXEMPLAR_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW) endif() if(WITH_THREAD_INSTRUMENTATION_PREVIEW) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW) endif() if(WITH_OTLP_HTTP_COMPRESSION) target_compile_definitions(opentelemetry_api INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW) endif() if(APPLE) target_link_libraries(opentelemetry_api INTERFACE "-framework CoreFoundation") endif() include(${PROJECT_SOURCE_DIR}/cmake/pkgconfig.cmake) if(OPENTELEMETRY_INSTALL) opentelemetry_add_pkgconfig( api "OpenTelemetry API" "A header-only library to support instrumentation with OpenTelemetry." "${TARGET_DEPS}") endif() opentelemetry-cpp-1.19.0/api/include/000077500000000000000000000000001474412371400174615ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/000077500000000000000000000000001474412371400223555ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/baggage/000077500000000000000000000000001474412371400237325ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/baggage/baggage.h000066400000000000000000000211341474412371400254610ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/common/kv_properties.h" #include "opentelemetry/common/macros.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace baggage { class OPENTELEMETRY_EXPORT Baggage { public: static constexpr size_t kMaxKeyValuePairs = 180; static constexpr size_t kMaxKeyValueSize = 4096; static constexpr size_t kMaxSize = 8192; static constexpr char kKeyValueSeparator = '='; static constexpr char kMembersSeparator = ','; static constexpr char kMetadataSeparator = ';'; Baggage() noexcept : kv_properties_(new common::KeyValueProperties()) {} Baggage(size_t size) noexcept : kv_properties_(new common::KeyValueProperties(size)) {} template Baggage(const T &keys_and_values) noexcept : kv_properties_(new common::KeyValueProperties(keys_and_values)) {} OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr GetDefault() { static nostd::shared_ptr baggage{new Baggage()}; return baggage; } /* Get value for key in the baggage @returns true if key is found, false otherwise */ bool GetValue(nostd::string_view key, std::string &value) const noexcept { return kv_properties_->GetValue(key, value); } /* Returns shared_ptr of new baggage object which contains new key-value pair. If key or value is invalid, copy of current baggage is returned */ nostd::shared_ptr Set(const nostd::string_view &key, const nostd::string_view &value) noexcept { nostd::shared_ptr baggage(new Baggage(kv_properties_->Size() + 1)); const bool valid_kv = IsValidKey(key) && IsValidValue(value); if (valid_kv) { baggage->kv_properties_->AddEntry(key, value); } // add rest of the fields. kv_properties_->GetAllEntries( [&baggage, &key, &valid_kv](nostd::string_view e_key, nostd::string_view e_value) { // if key or value was not valid, add all the entries. Add only remaining entries // otherwise. if (!valid_kv || key != e_key) { baggage->kv_properties_->AddEntry(e_key, e_value); } return true; }); return baggage; } // @return all key-values entries by repeatedly invoking the function reference passed as argument // for each entry bool GetAllEntries( nostd::function_ref callback) const noexcept { return kv_properties_->GetAllEntries(callback); } // delete key from the baggage if it exists. Returns shared_ptr of new baggage object. // if key does not exist, copy of current baggage is returned. // Validity of key is not checked as invalid keys should never be populated in baggage in the // first place. nostd::shared_ptr Delete(nostd::string_view key) noexcept { // keeping size of baggage same as key might not be found in it nostd::shared_ptr baggage(new Baggage(kv_properties_->Size())); kv_properties_->GetAllEntries( [&baggage, &key](nostd::string_view e_key, nostd::string_view e_value) { if (key != e_key) baggage->kv_properties_->AddEntry(e_key, e_value); return true; }); return baggage; } // Returns shared_ptr of baggage after extracting key-value pairs from header static nostd::shared_ptr FromHeader(nostd::string_view header) noexcept { if (header.size() > kMaxSize) { // header size exceeds maximum threshold, return empty baggage return GetDefault(); } common::KeyValueStringTokenizer kv_str_tokenizer(header); size_t cnt = kv_str_tokenizer.NumTokens(); // upper bound on number of kv pairs if (cnt > kMaxKeyValuePairs) { cnt = kMaxKeyValuePairs; } nostd::shared_ptr baggage(new Baggage(cnt)); bool kv_valid; nostd::string_view key, value; while (kv_str_tokenizer.next(kv_valid, key, value) && baggage->kv_properties_->Size() < cnt) { if (!kv_valid || (key.size() + value.size() > kMaxKeyValueSize)) { // if kv pair is not valid, skip it continue; } // NOTE : metadata is kept as part of value only as it does not have any semantic meaning. // but, we need to extract it (else Decode on value will return error) nostd::string_view metadata; auto metadata_separator = value.find(kMetadataSeparator); if (metadata_separator != std::string::npos) { metadata = value.substr(metadata_separator); value = value.substr(0, metadata_separator); } bool err = 0; auto key_str = UrlDecode(common::StringUtil::Trim(key), err); auto value_str = UrlDecode(common::StringUtil::Trim(value), err); if (err == false && IsValidKey(key_str) && IsValidValue(value_str)) { if (!metadata.empty()) { value_str.append(metadata.data(), metadata.size()); } baggage->kv_properties_->AddEntry(key_str, value_str); } } return baggage; } // Creates string from baggage object. std::string ToHeader() const noexcept { std::string header_s; bool first = true; kv_properties_->GetAllEntries([&](nostd::string_view key, nostd::string_view value) { if (!first) { header_s.push_back(kMembersSeparator); } else { first = false; } header_s.append(UrlEncode(key)); header_s.push_back(kKeyValueSeparator); // extracting metadata from value. We do not encode metadata auto metadata_separator = value.find(kMetadataSeparator); if (metadata_separator != std::string::npos) { header_s.append(UrlEncode(value.substr(0, metadata_separator))); auto metadata = value.substr(metadata_separator); header_s.append(std::string(metadata.data(), metadata.size())); } else { header_s.append(UrlEncode(value)); } return true; }); return header_s; } private: static bool IsPrintableString(nostd::string_view str) { for (const auto ch : str) { if (ch < ' ' || ch > '~') { return false; } } return true; } static bool IsValidKey(nostd::string_view key) { return key.size() && IsPrintableString(key); } static bool IsValidValue(nostd::string_view value) { return IsPrintableString(value); } // Uri encode key value pairs before injecting into header // Implementation inspired from : https://golang.org/src/net/url/url.go?s=7851:7884#L264 static std::string UrlEncode(nostd::string_view str) { auto to_hex = [](char c) -> char { static const char *hex = "0123456789ABCDEF"; return hex[c & 15]; }; std::string ret; for (auto c : str) { if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { ret.push_back(c); } else if (c == ' ') { ret.push_back('+'); } else { ret.push_back('%'); ret.push_back(to_hex(c >> 4)); ret.push_back(to_hex(c & 15)); } } return ret; } // Uri decode key value pairs after extracting from header static std::string UrlDecode(nostd::string_view str, bool &err) { auto IsHex = [](char c) { return std::isdigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'); }; auto from_hex = [](char c) -> char { // c - '0' produces integer type which could trigger error/warning when casting to char, // but the cast is safe here. return static_cast(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10); }; std::string ret; for (size_t i = 0; i < str.size(); i++) { if (str[i] == '%') { if (i + 2 >= str.size() || !IsHex(str[i + 1]) || !IsHex(str[i + 2])) { err = 1; return ""; } ret.push_back(from_hex(str[i + 1]) << 4 | from_hex(str[i + 2])); i += 2; } else if (str[i] == '+') { ret.push_back(' '); } else if (std::isalnum(str[i]) || str[i] == '-' || str[i] == '_' || str[i] == '.' || str[i] == '~') { ret.push_back(str[i]); } else { err = 1; return ""; } } return ret; } private: // Store entries in a C-style array to avoid using std::array or std::vector. nostd::unique_ptr kv_properties_; }; } // namespace baggage OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/baggage/baggage_context.h000066400000000000000000000020041474412371400272200ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/baggage/baggage.h" #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace baggage { static const std::string kBaggageHeader = "baggage"; inline nostd::shared_ptr GetBaggage(const context::Context &context) noexcept { context::ContextValue context_value = context.GetValue(kBaggageHeader); if (nostd::holds_alternative>(context_value)) { return nostd::get>(context_value); } static nostd::shared_ptr empty_baggage{new Baggage()}; return empty_baggage; } inline context::Context SetBaggage(context::Context &context, const nostd::shared_ptr &baggage) noexcept { return context.SetValue(kBaggageHeader, baggage); } } // namespace baggage OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/baggage/propagation/000077500000000000000000000000001474412371400262555ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/baggage/propagation/baggage_propagator.h000066400000000000000000000031031474412371400322360ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/baggage/baggage.h" #include "opentelemetry/baggage/baggage_context.h" #include "opentelemetry/context/context.h" #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace baggage { namespace propagation { class BaggagePropagator : public context::propagation::TextMapPropagator { public: void Inject(context::propagation::TextMapCarrier &carrier, const context::Context &context) noexcept override { auto baggage = baggage::GetBaggage(context); auto header = baggage->ToHeader(); if (header.size()) { carrier.Set(kBaggageHeader, header); } } context::Context Extract(const context::propagation::TextMapCarrier &carrier, context::Context &context) noexcept override { nostd::string_view baggage_str = carrier.Get(baggage::kBaggageHeader); auto baggage = baggage::Baggage::FromHeader(baggage_str); if (baggage->ToHeader().size()) { return baggage::SetBaggage(context, baggage); } else { return context; } } bool Fields(nostd::function_ref callback) const noexcept override { return callback(kBaggageHeader); } }; } // namespace propagation } // namespace baggage OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/000077500000000000000000000000001474412371400236455ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/attribute_value.h000066400000000000000000000052611474412371400272210ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { /// OpenTelemetry signals can be enriched by adding attributes. The /// \c AttributeValue type is defined as a variant of all attribute value /// types the OpenTelemetry C++ API supports. /// /// The following attribute value types are supported by the OpenTelemetry /// specification: /// - Primitive types: string, boolean, double precision floating point /// (IEEE 754-1985) or signed 64 bit integer. /// - Homogenous arrays of primitive type values. /// /// \warning /// \parblock The OpenTelemetry C++ API currently supports several attribute /// value types that are not covered by the OpenTelemetry specification: /// - \c uint64_t /// - \c nostd::span /// - \c nostd::span /// /// Those types are reserved for future use and currently should not be /// used. There are no guarantees around how those values are handled by /// exporters. /// \endparblock using AttributeValue = nostd::variant, nostd::span, nostd::span, nostd::span, nostd::span, nostd::span, // Not currently supported by the specification, but reserved for future use. // Added to provide support for all primitive C++ types. uint64_t, // Not currently supported by the specification, but reserved for future use. // Added to provide support for all primitive C++ types. nostd::span, // Not currently supported by the specification, but reserved for future use. // See https://github.com/open-telemetry/opentelemetry-specification/issues/780 nostd::span>; enum AttributeType { kTypeBool, kTypeInt, kTypeInt64, kTypeUInt, kTypeDouble, kTypeCString, kTypeString, kTypeSpanBool, kTypeSpanInt, kTypeSpanInt64, kTypeSpanUInt, kTypeSpanDouble, kTypeSpanString, kTypeUInt64, kTypeSpanUInt64, kTypeSpanByte }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/key_value_iterable.h000066400000000000000000000032471474412371400276570ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { /** * Supports internal iteration over a collection of key-value pairs. */ class KeyValueIterable { public: virtual ~KeyValueIterable() = default; /** * Iterate over key-value pairs * @param callback a callback to invoke for each key-value. If the callback returns false, * the iteration is aborted. * @return true if every key-value pair was iterated over */ virtual bool ForEachKeyValue(nostd::function_ref callback) const noexcept = 0; /** * @return the number of key-value pairs */ virtual size_t size() const noexcept = 0; }; /** * Supports internal iteration over a collection of key-value pairs. */ class NoopKeyValueIterable : public KeyValueIterable { public: ~NoopKeyValueIterable() override = default; /** * Iterate over key-value pairs * @param callback a callback to invoke for each key-value. If the callback returns false, * the iteration is aborted. * @return true if every key-value pair was iterated over */ bool ForEachKeyValue( nostd::function_ref) const noexcept override { return true; } /** * @return the number of key-value pairs */ size_t size() const noexcept override { return 0; } }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/key_value_iterable_view.h000066400000000000000000000111671474412371400307110ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include #include #include #include #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/nostd/utility.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { // NOTE - code within `detail` namespace implements internal details, and not part // of the public interface. namespace detail { inline void take_key_value(nostd::string_view, common::AttributeValue) {} template auto is_key_value_iterable_impl(T iterable) -> decltype(take_key_value(std::begin(iterable)->first, std::begin(iterable)->second), nostd::size(iterable), std::true_type{}); std::false_type is_key_value_iterable_impl(...); template struct is_key_value_iterable { static const bool value = decltype(detail::is_key_value_iterable_impl(std::declval()))::value; }; } // namespace detail /** * @brief Container for key-value pairs that can transform every value in it to one of types * listed in common::AttributeValue. It may contain value types that are not directly map'able * to primitive value types. In that case the `ForEachKeyValue` method acts as a transform to * convert the value type to one listed under AtributeValue (bool, int32_t, int64_t, uint32_t, * uint64_t, double, nostd::string_view, or arrays of primite types). For example, if UUID, * GUID, or UTF-16 string type is passed as one of values stored inside this container, the * container itself may provide a custom implementation of `ForEachKeyValue` to transform the * 'non-standard' type to one of the standard types. */ template class KeyValueIterableView final : public KeyValueIterable { public: explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {} // KeyValueIterable bool ForEachKeyValue(nostd::function_ref callback) const noexcept override { auto iter = std::begin(*container_); auto last = std::end(*container_); for (; iter != last; ++iter) { if (!callback(iter->first, iter->second)) { return false; } } return true; } size_t size() const noexcept override { return nostd::size(*container_); } private: const T *container_; }; template ::value> * = nullptr> KeyValueIterableView MakeKeyValueIterableView(const T &container) noexcept { return KeyValueIterableView(container); } /** * Utility function to help to make a attribute view from initializer_list * * @param attributes * @return nostd::span> */ inline static nostd::span> MakeAttributes(std::initializer_list> attributes) noexcept { return nostd::span>{ attributes.begin(), attributes.end()}; } /** * Utility function to help to make a attribute view from a span * * @param attributes * @return nostd::span> */ inline static nostd::span> MakeAttributes( nostd::span> attributes) noexcept { return attributes; } /** * Utility function to help to make a attribute view from a KeyValueIterable * * @param attributes * @return common::KeyValueIterable */ inline static const common::KeyValueIterable &MakeAttributes( const common::KeyValueIterable &attributes) noexcept { return attributes; } /** * Utility function to help to make a attribute view from a key-value iterable object * * @param attributes * @return nostd::span> */ template < class ArgumentType, nostd::enable_if_t::value> * = nullptr> inline static common::KeyValueIterableView MakeAttributes( const ArgumentType &arg) noexcept { return common::KeyValueIterableView(arg); } } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/kv_properties.h000066400000000000000000000163421474412371400267200ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/common/string_util.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" #include #include #include OPENTELEMETRY_BEGIN_NAMESPACE namespace common { // Constructor parameter for KeyValueStringTokenizer struct KeyValueStringTokenizerOptions { char member_separator = ','; char key_value_separator = '='; bool ignore_empty_members = true; }; // Tokenizer for key-value headers class KeyValueStringTokenizer { public: KeyValueStringTokenizer( nostd::string_view str, const KeyValueStringTokenizerOptions &opts = KeyValueStringTokenizerOptions()) noexcept : str_(str), opts_(opts), index_(0) {} static nostd::string_view GetDefaultKeyOrValue() { static std::string default_str = ""; return default_str; } // Returns next key value in the string header // @param valid_kv : if the found kv pair is valid or not // @param key : key in kv pair // @param key : value in kv pair // @returns true if next kv pair was found, false otherwise. bool next(bool &valid_kv, nostd::string_view &key, nostd::string_view &value) noexcept { valid_kv = true; while (index_ < str_.size()) { bool is_empty_pair = false; size_t end = str_.find(opts_.member_separator, index_); if (end == std::string::npos) { end = str_.size() - 1; } else if (end == index_) // empty pair. do not update end { is_empty_pair = true; } else { end--; } auto list_member = StringUtil::Trim(str_, index_, end); if (list_member.size() == 0 || is_empty_pair) { // empty list member index_ = end + 2 - is_empty_pair; if (opts_.ignore_empty_members) { continue; } valid_kv = true; key = GetDefaultKeyOrValue(); value = GetDefaultKeyOrValue(); return true; } auto key_end_pos = list_member.find(opts_.key_value_separator); if (key_end_pos == std::string::npos) { // invalid member valid_kv = false; } else { key = list_member.substr(0, key_end_pos); value = list_member.substr(key_end_pos + 1); } index_ = end + 2; return true; } // no more entries remaining return false; } // Returns total number of tokens in header string size_t NumTokens() const noexcept { size_t cnt = 0, begin = 0; while (begin < str_.size()) { ++cnt; size_t end = str_.find(opts_.member_separator, begin); if (end == std::string::npos) { break; } begin = end + 1; } return cnt; } // Resets the iterator void reset() noexcept { index_ = 0; } private: nostd::string_view str_; KeyValueStringTokenizerOptions opts_; size_t index_; }; // Class to store fixed size array of key-value pairs of string type class KeyValueProperties { // Class to store key-value pairs of string types public: class Entry { public: Entry() : key_(nullptr), value_(nullptr) {} // Copy constructor Entry(const Entry ©) { key_ = CopyStringToPointer(copy.key_.get()); value_ = CopyStringToPointer(copy.value_.get()); } // Copy assignment operator Entry &operator=(Entry &other) { key_ = CopyStringToPointer(other.key_.get()); value_ = CopyStringToPointer(other.value_.get()); return *this; } // Move contructor and assignment operator Entry(Entry &&other) = default; Entry &operator=(Entry &&other) = default; // Creates an Entry for a given key-value pair. Entry(nostd::string_view key, nostd::string_view value) { key_ = CopyStringToPointer(key); value_ = CopyStringToPointer(value); } // Gets the key associated with this entry. nostd::string_view GetKey() const noexcept { return key_.get(); } // Gets the value associated with this entry. nostd::string_view GetValue() const noexcept { return value_.get(); } // Sets the value for this entry. This overrides the previous value. void SetValue(nostd::string_view value) noexcept { value_ = CopyStringToPointer(value); } private: // Store key and value as raw char pointers to avoid using std::string. nostd::unique_ptr key_; nostd::unique_ptr value_; // Copies string into a buffer and returns a unique_ptr to the buffer. // This is a workaround for the fact that memcpy doesn't accept a const destination. nostd::unique_ptr CopyStringToPointer(nostd::string_view str) { char *temp = new char[str.size() + 1]; memcpy(temp, str.data(), str.size()); temp[str.size()] = '\0'; return nostd::unique_ptr(temp); } }; // Maintain the number of entries in entries_. size_t num_entries_; // Max size of allocated array size_t max_num_entries_; // Store entries in a C-style array to avoid using std::array or std::vector. nostd::unique_ptr entries_; public: // Create Key-value list of given size // @param size : Size of list. KeyValueProperties(size_t size) noexcept : num_entries_(0), max_num_entries_(size), entries_(new Entry[size]) {} // Create Empty Key-Value list KeyValueProperties() noexcept : num_entries_(0), max_num_entries_(0), entries_(nullptr) {} template ::value>::type> KeyValueProperties(const T &keys_and_values) noexcept : num_entries_(0), max_num_entries_(keys_and_values.size()), entries_(new Entry[max_num_entries_]) { for (auto &e : keys_and_values) { Entry entry(e.first, e.second); (entries_.get())[num_entries_++] = std::move(entry); } } // Adds new kv pair into kv properties void AddEntry(nostd::string_view key, nostd::string_view value) noexcept { if (num_entries_ < max_num_entries_) { Entry entry(key, value); (entries_.get())[num_entries_++] = std::move(entry); } } // Returns all kv pair entries bool GetAllEntries( nostd::function_ref callback) const noexcept { for (size_t i = 0; i < num_entries_; i++) { auto &entry = (entries_.get())[i]; if (!callback(entry.GetKey(), entry.GetValue())) { return false; } } return true; } // Return value for key if exists, return false otherwise bool GetValue(nostd::string_view key, std::string &value) const noexcept { for (size_t i = 0; i < num_entries_; i++) { auto &entry = (entries_.get())[i]; if (entry.GetKey() == key) { const auto &entry_value = entry.GetValue(); value = std::string(entry_value.data(), entry_value.size()); return true; } } return false; } size_t Size() const noexcept { return num_entries_; } }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/macros.h000066400000000000000000000415051474412371400253070ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once /* OPENTELEMETRY_HAVE_BUILTIN&OPENTELEMETRY_HAVE_FEATURE Checks whether the compiler supports a Clang Feature Checking Macro, and if so, checks whether it supports the provided builtin function "x" where x is one of the functions noted in https://clang.llvm.org/docs/LanguageExtensions.html Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html */ #if !defined(OPENTELEMETRY_HAVE_BUILTIN) # ifdef __has_builtin # define OPENTELEMETRY_HAVE_BUILTIN(x) __has_builtin(x) # else # define OPENTELEMETRY_HAVE_BUILTIN(x) 0 # endif #endif #if !defined(OPENTELEMETRY_HAVE_FEATURE) # ifdef __has_feature # define OPENTELEMETRY_HAVE_FEATURE(f) __has_feature(f) # else # define OPENTELEMETRY_HAVE_FEATURE(f) 0 # endif #endif /* has feature OPENTELEMETRY_HAVE_ATTRIBUTE A function-like feature checking macro that is a wrapper around `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a nonzero constant integer if the attribute is supported or 0 if not. It evaluates to zero if `__has_attribute` is not defined by the compiler. GCC: https://gcc.gnu.org/gcc-5/changes.html Clang: https://clang.llvm.org/docs/LanguageExtensions.html */ #if !defined(OPENTELEMETRY_HAVE_ATTRIBUTE) # ifdef __has_attribute # define OPENTELEMETRY_HAVE_ATTRIBUTE(x) __has_attribute(x) # else # define OPENTELEMETRY_HAVE_ATTRIBUTE(x) 0 # endif #endif /* OPENTELEMETRY_HAVE_CPP_ATTRIBUTE A function-like feature checking macro that accepts C++11 style attributes. It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't find `__has_cpp_attribute`, will evaluate to 0. */ #if !defined(OPENTELEMETRY_HAVE_CPP_ATTRIBUTE) # if defined(__cplusplus) && defined(__has_cpp_attribute) // NOTE: requiring __cplusplus above should not be necessary, but // works around https://bugs.llvm.org/show_bug.cgi?id=23435. # define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) # else # define OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(x) 0 # endif #endif /* Expected usage pattern: if OPENTELEMETRY_LIKELY_CONDITION (ptr != nullptr) { do_something_likely(); } else { do_something_unlikely(); } This pattern works with gcc/clang and __builtin_expect(), as well as with C++20. It is unclear if __builtin_expect() will be deprecated in favor of C++20 [[likely]] or not. OPENTELEMETRY_LIKELY_CONDITION is preferred over OPENTELEMETRY_LIKELY, to be revisited when C++20 is required. */ #if !defined(OPENTELEMETRY_LIKELY_CONDITION) && defined(__cplusplus) // Only use likely with C++20 # if __cplusplus >= 202002L // GCC 9 has likely attribute but do not support declare it at the beginning of statement # if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) # if __has_cpp_attribute(likely) # define OPENTELEMETRY_LIKELY_CONDITION(C) (C) [[likely]] # endif # endif # endif #endif #if !defined(OPENTELEMETRY_LIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__)) // Only use if supported by the compiler # define OPENTELEMETRY_LIKELY_CONDITION(C) (__builtin_expect(!!(C), true)) #endif #ifndef OPENTELEMETRY_LIKELY_CONDITION // Do not use likely annotations # define OPENTELEMETRY_LIKELY_CONDITION(C) (C) #endif #if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && defined(__cplusplus) // Only use unlikely with C++20 # if __cplusplus >= 202002L // GCC 9 has unlikely attribute but do not support declare it at the beginning of statement # if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) # if __has_cpp_attribute(unlikely) # define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) [[unlikely]] # endif # endif # endif #endif #if !defined(OPENTELEMETRY_UNLIKELY_CONDITION) && (defined(__clang__) || defined(__GNUC__)) // Only use if supported by the compiler # define OPENTELEMETRY_UNLIKELY_CONDITION(C) (__builtin_expect(!!(C), false)) #endif #ifndef OPENTELEMETRY_UNLIKELY_CONDITION // Do not use unlikely annotations # define OPENTELEMETRY_UNLIKELY_CONDITION(C) (C) #endif /* Expected usage pattern: if (ptr != nullptr) OPENTELEMETRY_LIKELY { do_something_likely(); } else { do_something_unlikely(); } This pattern works starting with C++20. See https://en.cppreference.com/w/cpp/language/attributes/likely Please use OPENTELEMETRY_LIKELY_CONDITION instead for now. */ #if !defined(OPENTELEMETRY_LIKELY) && defined(__cplusplus) // Only use likely with C++20 # if __cplusplus >= 202002L // GCC 9 has likely attribute but do not support declare it at the beginning of statement # if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) # if __has_cpp_attribute(likely) # define OPENTELEMETRY_LIKELY [[likely]] # endif # endif # endif #endif #ifndef OPENTELEMETRY_LIKELY # define OPENTELEMETRY_LIKELY #endif #if !defined(OPENTELEMETRY_UNLIKELY) && defined(__cplusplus) // Only use unlikely with C++20 # if __cplusplus >= 202002L // GCC 9 has unlikely attribute but do not support declare it at the beginning of statement # if defined(__has_cpp_attribute) && (defined(__clang__) || !defined(__GNUC__) || __GNUC__ > 9) # if __has_cpp_attribute(unlikely) # define OPENTELEMETRY_UNLIKELY [[unlikely]] # endif # endif # endif #endif #ifndef OPENTELEMETRY_UNLIKELY # define OPENTELEMETRY_UNLIKELY #endif /// \brief Declare variable as maybe unused /// usage: /// OPENTELEMETRY_MAYBE_UNUSED int a; /// class OPENTELEMETRY_MAYBE_UNUSED a; /// OPENTELEMETRY_MAYBE_UNUSED int a(); /// #if defined(__cplusplus) && __cplusplus >= 201703L # define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]] #elif defined(__clang__) # define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused)) #elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) # define OPENTELEMETRY_MAYBE_UNUSED __attribute__((unused)) #elif (defined(_MSC_VER) && _MSC_VER >= 1910) && (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) # define OPENTELEMETRY_MAYBE_UNUSED [[maybe_unused]] #else # define OPENTELEMETRY_MAYBE_UNUSED #endif #ifndef OPENTELEMETRY_RTTI_ENABLED # if defined(__clang__) # if __has_feature(cxx_rtti) # define OPENTELEMETRY_RTTI_ENABLED # endif # elif defined(__GNUG__) # if defined(__GXX_RTTI) # define OPENTELEMETRY_RTTI_ENABLED # endif # elif defined(_MSC_VER) # if defined(_CPPRTTI) # define OPENTELEMETRY_RTTI_ENABLED # endif # endif #endif #if defined(__cplusplus) && __cplusplus >= 201402L # define OPENTELEMETRY_DEPRECATED [[deprecated]] #elif defined(__clang__) # define OPENTELEMETRY_DEPRECATED __attribute__((deprecated)) #elif defined(__GNUC__) # define OPENTELEMETRY_DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L # define OPENTELEMETRY_DEPRECATED [[deprecated]] # else # define OPENTELEMETRY_DEPRECATED __declspec(deprecated) # endif #else # define OPENTELEMETRY_DEPRECATED #endif #if defined(__cplusplus) && __cplusplus >= 201402L # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]] #elif defined(__clang__) # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg))) #elif defined(__GNUC__) # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __attribute__((deprecated(msg))) #elif defined(_MSC_VER) # if _MSC_VER >= 1910 && defined(_MSVC_LANG) && _MSVC_LANG >= 201703L # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) [[deprecated(msg)]] # else # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) __declspec(deprecated(msg)) # endif #else # define OPENTELEMETRY_DEPRECATED_MESSAGE(msg) #endif // Regex support #if (__GNUC__ == 4 && (__GNUC_MINOR__ == 8 || __GNUC_MINOR__ == 9)) # define OPENTELEMETRY_HAVE_WORKING_REGEX 0 #else # define OPENTELEMETRY_HAVE_WORKING_REGEX 1 #endif /* clang-format off */ /** @page HEADER_ONLY_SINGLETON Header only singleton. @section ELF_SINGLETON For clang and gcc, the desired coding pattern is as follows. @verbatim class Foo { // (a) __attribute__((visibility("default"))) // (b) T& get_singleton() { // (c) static T singleton; return singleton; } }; @endverbatim (a) is needed when the code is build with @code -fvisibility="hidden" @endcode to ensure that all instances of (b) are visible to the linker. What is duplicated in the binary is @em code, in (b). The linker will make sure only one instance of all the (b) methods is used. (c) is a singleton implemented inside a method. This is very desirable, because: - the C++ compiler guarantees that construction of the variable (c) is thread safe. - constructors for (c) singletons are executed in code path order, or not at all if the singleton is never used. @section OTHER_SINGLETON For other platforms, header only singletons are not supported at this point. @section CODING_PATTERN The coding pattern to use in the source code is as follows @verbatim class Foo { OPENTELEMETRY_API_SINGLETON T& get_singleton() { static T singleton; return singleton; } }; @endverbatim */ /* clang-format on */ #if defined(__clang__) # define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default"))) # define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden"))) #elif defined(__GNUC__) # define OPENTELEMETRY_API_SINGLETON __attribute__((visibility("default"))) # define OPENTELEMETRY_LOCAL_SYMBOL __attribute__((visibility("hidden"))) #else /* Add support for other compilers here. */ # define OPENTELEMETRY_API_SINGLETON # define OPENTELEMETRY_LOCAL_SYMBOL #endif // // Atomic wrappers based on compiler intrinsics for memory read/write. // The tailing number is read/write length in bits. // // N.B. Compiler instrinsic is used because the usage of C++ standard library is restricted in the // OpenTelemetry C++ API. // #if defined(__GNUC__) # define OPENTELEMETRY_ATOMIC_READ_8(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST) # define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST) #elif defined(_MSC_VER) # include # define OPENTELEMETRY_ATOMIC_READ_8(ptr) \ static_cast(_InterlockedCompareExchange8(reinterpret_cast(ptr), 0, 0)) # define OPENTELEMETRY_ATOMIC_WRITE_8(ptr, value) \ _InterlockedExchange8(reinterpret_cast(ptr), static_cast(value)) #else # error port atomics read/write for the current platform #endif /* clang-format on */ // // The if/elif order matters here. If both OPENTELEMETRY_BUILD_IMPORT_DLL and // OPENTELEMETRY_BUILD_EXPORT_DLL are defined, the former takes precedence. // // TODO: consider define OPENTELEMETRY_EXPORT for cygwin/gcc, see below link. // https://gcc.gnu.org/wiki/Visibility#How_to_use_the_new_C.2B-.2B-_visibility_support // #if defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_IMPORT_DLL) # define OPENTELEMETRY_EXPORT __declspec(dllimport) #elif defined(_MSC_VER) && defined(OPENTELEMETRY_BUILD_EXPORT_DLL) # define OPENTELEMETRY_EXPORT __declspec(dllexport) #else // // build OpenTelemetry as static library or not on Windows. // # define OPENTELEMETRY_EXPORT #endif // OPENTELEMETRY_HAVE_EXCEPTIONS // // Checks whether the compiler both supports and enables exceptions. Many // compilers support a "no exceptions" mode that disables exceptions. // // Generally, when OPENTELEMETRY_HAVE_EXCEPTIONS is not defined: // // * Code using `throw` and `try` may not compile. // * The `noexcept` specifier will still compile and behave as normal. // * The `noexcept` operator may still return `false`. // // For further details, consult the compiler's documentation. #ifndef OPENTELEMETRY_HAVE_EXCEPTIONS # if defined(__clang__) && ((__clang_major__ * 100) + __clang_minor__) < 306 // Clang < 3.6 // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro # if defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) # define OPENTELEMETRY_HAVE_EXCEPTIONS 1 # endif // defined(__EXCEPTIONS) && OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) # elif OPENTELEMETRY_HAVE_FEATURE(cxx_exceptions) # define OPENTELEMETRY_HAVE_EXCEPTIONS 1 // Handle remaining special cases and default to exceptions being supported. # elif !(defined(__GNUC__) && !defined(__EXCEPTIONS) && !defined(__cpp_exceptions)) && \ !(defined(_MSC_VER) && !defined(_CPPUNWIND)) # define OPENTELEMETRY_HAVE_EXCEPTIONS 1 # endif #endif #ifndef OPENTELEMETRY_HAVE_EXCEPTIONS # define OPENTELEMETRY_HAVE_EXCEPTIONS 0 #endif /* OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND indicates that a resource owned by a function parameter or implicit object parameter is retained by the return value of the annotated function (or, for a parameter of a constructor, in the value of the constructed object). This attribute causes warnings to be produced if a temporary object does not live long enough. When applied to a reference parameter, the referenced object is assumed to be retained by the return value of the function. When applied to a non-reference parameter (for example, a pointer or a class type), all temporaries referenced by the parameter are assumed to be retained by the return value of the function. See also the upstream documentation: https://clang.llvm.org/docs/AttributeReference.html#lifetimebound */ #ifndef OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND # if OPENTELEMETRY_HAVE_CPP_ATTRIBUTE(clang::lifetimebound) # define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]] # elif OPENTELEMETRY_HAVE_ATTRIBUTE(lifetimebound) # define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound)) # else # define OPENTELEMETRY_ATTRIBUTE_LIFETIME_BOUND # endif #endif // OPENTELEMETRY_HAVE_MEMORY_SANITIZER // // MemorySanitizer (MSan) is a detector of uninitialized reads. It consists of // a compiler instrumentation module and a run-time library. #ifndef OPENTELEMETRY_HAVE_MEMORY_SANITIZER # if !defined(__native_client__) && OPENTELEMETRY_HAVE_FEATURE(memory_sanitizer) # define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 1 # else # define OPENTELEMETRY_HAVE_MEMORY_SANITIZER 0 # endif #endif #if OPENTELEMETRY_HAVE_MEMORY_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_memory) # define OPENTELEMETRY_SANITIZER_NO_MEMORY \ __attribute__((no_sanitize_memory)) // __attribute__((no_sanitize("memory"))) #else # define OPENTELEMETRY_SANITIZER_NO_MEMORY #endif // OPENTELEMETRY_HAVE_THREAD_SANITIZER // // ThreadSanitizer (TSan) is a fast data race detector. #ifndef OPENTELEMETRY_HAVE_THREAD_SANITIZER # if defined(__SANITIZE_THREAD__) # define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 # elif OPENTELEMETRY_HAVE_FEATURE(thread_sanitizer) # define OPENTELEMETRY_HAVE_THREAD_SANITIZER 1 # else # define OPENTELEMETRY_HAVE_THREAD_SANITIZER 0 # endif #endif #if OPENTELEMETRY_HAVE_THREAD_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_thread) # define OPENTELEMETRY_SANITIZER_NO_THREAD \ __attribute__((no_sanitize_thread)) // __attribute__((no_sanitize("thread"))) #else # define OPENTELEMETRY_SANITIZER_NO_THREAD #endif // OPENTELEMETRY_HAVE_ADDRESS_SANITIZER // // AddressSanitizer (ASan) is a fast memory error detector. #ifndef OPENTELEMETRY_HAVE_ADDRESS_SANITIZER # if defined(__SANITIZE_ADDRESS__) # define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 # elif OPENTELEMETRY_HAVE_FEATURE(address_sanitizer) # define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 1 # else # define OPENTELEMETRY_HAVE_ADDRESS_SANITIZER 0 # endif #endif // OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER // // Hardware-Assisted AddressSanitizer (or HWASAN) is even faster than asan // memory error detector which can use CPU features like ARM TBI, Intel LAM or // AMD UAI. #ifndef OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER # if defined(__SANITIZE_HWADDRESS__) # define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 # elif OPENTELEMETRY_HAVE_FEATURE(hwaddress_sanitizer) # define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 1 # else # define OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER 0 # endif #endif #if OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize_address) # define OPENTELEMETRY_SANITIZER_NO_ADDRESS \ __attribute__((no_sanitize_address)) // __attribute__((no_sanitize("address"))) #elif OPENTELEMETRY_HAVE_ADDRESS_SANITIZER && defined(_MSC_VER) && _MSC_VER >= 1928 # define OPENTELEMETRY_SANITIZER_NO_ADDRESS __declspec(no_sanitize_address) #elif OPENTELEMETRY_HAVE_HWADDRESS_SANITIZER && OPENTELEMETRY_HAVE_ATTRIBUTE(no_sanitize) # define OPENTELEMETRY_SANITIZER_NO_ADDRESS __attribute__((no_sanitize("hwaddress"))) #else # define OPENTELEMETRY_SANITIZER_NO_ADDRESS #endif opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/spin_lock_mutex.h000066400000000000000000000076011474412371400272250ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include #include "opentelemetry/version.h" #if defined(_MSC_VER) # define _WINSOCKAPI_ // stops including winsock.h # include #elif defined(__i386__) || defined(__x86_64__) # if defined(__clang__) # include # elif defined(__INTEL_COMPILER) # include # endif #endif OPENTELEMETRY_BEGIN_NAMESPACE namespace common { constexpr int SPINLOCK_FAST_ITERATIONS = 100; constexpr int SPINLOCK_SLEEP_MS = 1; /** * A Mutex which uses atomic flags and spin-locks instead of halting threads. * * This mutex uses an incremental back-off strategy with the following phases: * 1. A tight spin-lock loop (pending: using hardware PAUSE/YIELD instructions) * 2. A loop where the current thread yields control after checking the lock. * 3. Issuing a thread-sleep call before starting back in phase 1. * * This is meant to give a good balance of perofrmance and CPU consumption in * practice. * * This mutex uses an incremental back-off strategy with the following phases: * 1. A tight spin-lock loop (pending: using hardware PAUSE/YIELD instructions) * 2. A loop where the current thread yields control after checking the lock. * 3. Issuing a thread-sleep call before starting back in phase 1. * * This is meant to give a good balance of perofrmance and CPU consumption in * practice. * * This class implements the `BasicLockable` specification: * https://en.cppreference.com/w/cpp/named_req/BasicLockable */ class SpinLockMutex { public: SpinLockMutex() noexcept {} ~SpinLockMutex() noexcept = default; SpinLockMutex(const SpinLockMutex &) = delete; SpinLockMutex &operator=(const SpinLockMutex &) = delete; static inline void fast_yield() noexcept { // Issue a Pause/Yield instruction while spinning. #if defined(_MSC_VER) YieldProcessor(); #elif defined(__i386__) || defined(__x86_64__) # if defined(__clang__) || defined(__INTEL_COMPILER) _mm_pause(); # else __builtin_ia32_pause(); # endif #elif defined(__armel__) || defined(__ARMEL__) asm volatile("nop" ::: "memory"); #elif defined(__arm__) || defined(__aarch64__) // arm big endian / arm64 __asm__ __volatile__("yield" ::: "memory"); #else // TODO: Issue PAGE/YIELD on other architectures. #endif } /** * Attempts to lock the mutex. Return immediately with `true` (success) or `false` (failure). */ bool try_lock() noexcept { return !flag_.load(std::memory_order_relaxed) && !flag_.exchange(true, std::memory_order_acquire); } /** * Blocks until a lock can be obtained for the current thread. * * This mutex will spin the current CPU waiting for the lock to be available. This can have * decent performance in scenarios where there is low lock contention and lock-holders achieve * their work quickly. It degrades in scenarios where locked tasks take a long time. */ void lock() noexcept { for (;;) { // Try once if (!flag_.exchange(true, std::memory_order_acquire)) { return; } // Spin-Fast (goal ~10ns) for (std::size_t i = 0; i < SPINLOCK_FAST_ITERATIONS; ++i) { if (try_lock()) { return; } fast_yield(); } // Yield then try again (goal ~100ns) std::this_thread::yield(); if (try_lock()) { return; } // Sleep and then start the whole process again. (goal ~1000ns) std::this_thread::sleep_for(std::chrono::milliseconds(SPINLOCK_SLEEP_MS)); } return; } /** Releases the lock held by the execution agent. Throws no exceptions. */ void unlock() noexcept { flag_.store(false, std::memory_order_release); } private: std::atomic flag_{false}; }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/string_util.h000066400000000000000000000014051474412371400263610ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { class StringUtil { public: static nostd::string_view Trim(nostd::string_view str, size_t left, size_t right) noexcept { while (left <= right && isspace(str[left])) { left++; } while (left <= right && isspace(str[right])) { right--; } return str.substr(left, 1 + right - left); } static nostd::string_view Trim(nostd::string_view str) noexcept { if (str.empty()) { return str; } return Trim(str, 0, str.size() - 1); } }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/common/timestamp.h000066400000000000000000000135531474412371400260300ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { /** * @brief A timepoint relative to the system clock epoch. * * This is used for marking the beginning and end of an operation. */ class SystemTimestamp { public: /** * @brief Initializes a system timestamp pointing to the start of the epoch. */ SystemTimestamp() noexcept : nanos_since_epoch_{0} {} /** * @brief Initializes a system timestamp from a duration. * * @param time_since_epoch Time elapsed since the beginning of the epoch. */ template explicit SystemTimestamp(const std::chrono::duration &time_since_epoch) noexcept : nanos_since_epoch_{static_cast( std::chrono::duration_cast(time_since_epoch).count())} {} /** * @brief Initializes a system timestamp based on a point in time. * * @param time_point A point in time. */ /*implicit*/ SystemTimestamp(const std::chrono::system_clock::time_point &time_point) noexcept : SystemTimestamp{time_point.time_since_epoch()} {} /** * @brief Returns a time point for the time stamp. * * @return A time point corresponding to the time stamp. */ operator std::chrono::system_clock::time_point() const noexcept { return std::chrono::system_clock::time_point{ std::chrono::duration_cast( std::chrono::nanoseconds{nanos_since_epoch_})}; } /** * @brief Returns the nanoseconds since the beginning of the epoch. * * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. */ std::chrono::nanoseconds time_since_epoch() const noexcept { return std::chrono::nanoseconds{nanos_since_epoch_}; } /** * @brief Compare two steady time stamps. * * @return true if the two time stamps are equal. */ bool operator==(const SystemTimestamp &other) const noexcept { return nanos_since_epoch_ == other.nanos_since_epoch_; } /** * @brief Compare two steady time stamps for inequality. * * @return true if the two time stamps are not equal. */ bool operator!=(const SystemTimestamp &other) const noexcept { return nanos_since_epoch_ != other.nanos_since_epoch_; } private: int64_t nanos_since_epoch_; }; /** * @brief A timepoint relative to the monotonic clock epoch * * This is used for calculating the duration of an operation. */ class SteadyTimestamp { public: /** * @brief Initializes a monotonic timestamp pointing to the start of the epoch. */ SteadyTimestamp() noexcept : nanos_since_epoch_{0} {} /** * @brief Initializes a monotonic timestamp from a duration. * * @param time_since_epoch Time elapsed since the beginning of the epoch. */ template explicit SteadyTimestamp(const std::chrono::duration &time_since_epoch) noexcept : nanos_since_epoch_{static_cast( std::chrono::duration_cast(time_since_epoch).count())} {} /** * @brief Initializes a monotonic timestamp based on a point in time. * * @param time_point A point in time. */ /*implicit*/ SteadyTimestamp(const std::chrono::steady_clock::time_point &time_point) noexcept : SteadyTimestamp{time_point.time_since_epoch()} {} /** * @brief Returns a time point for the time stamp. * * @return A time point corresponding to the time stamp. */ operator std::chrono::steady_clock::time_point() const noexcept { return std::chrono::steady_clock::time_point{ std::chrono::duration_cast( std::chrono::nanoseconds{nanos_since_epoch_})}; } /** * @brief Returns the nanoseconds since the beginning of the epoch. * * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. */ std::chrono::nanoseconds time_since_epoch() const noexcept { return std::chrono::nanoseconds{nanos_since_epoch_}; } /** * @brief Compare two steady time stamps. * * @return true if the two time stamps are equal. */ bool operator==(const SteadyTimestamp &other) const noexcept { return nanos_since_epoch_ == other.nanos_since_epoch_; } /** * @brief Compare two steady time stamps for inequality. * * @return true if the two time stamps are not equal. */ bool operator!=(const SteadyTimestamp &other) const noexcept { return nanos_since_epoch_ != other.nanos_since_epoch_; } private: int64_t nanos_since_epoch_; }; class DurationUtil { public: template static std::chrono::duration AdjustWaitForTimeout( std::chrono::duration timeout, std::chrono::duration indefinite_value) noexcept { // Do not call now() when this duration is max value, now() may have a expensive cost. if (timeout == (std::chrono::duration::max)()) { return indefinite_value; } // std::future::wait_for, std::this_thread::sleep_for, and std::condition_variable::wait_for // may use steady_clock or system_clock.We need make sure now() + timeout do not overflow. auto max_timeout = std::chrono::duration_cast>( (std::chrono::steady_clock::time_point::max)() - std::chrono::steady_clock::now()); if (timeout >= max_timeout) { return indefinite_value; } max_timeout = std::chrono::duration_cast>( (std::chrono::system_clock::time_point::max)() - std::chrono::system_clock::now()); if (timeout >= max_timeout) { return indefinite_value; } return timeout; } }; } // namespace common OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/config.h000066400000000000000000000005551474412371400240000ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #ifndef __has_include # define OPENTELEMETRY_HAS_INCLUDE(x) 0 #else # define OPENTELEMETRY_HAS_INCLUDE(x) __has_include(x) #endif #if !defined(__GLIBCXX__) || OPENTELEMETRY_HAS_INCLUDE() // >= libstdc++-5 # define OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS #endif opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/000077500000000000000000000000001474412371400240415ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/context.h000066400000000000000000000113231474412371400256760ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { // The context class provides a context identifier. Is built as a linked list // of DataList nodes and each context holds a shared_ptr to a place within // the list that determines which keys and values it has access to. All that // come before and none that come after. class Context { public: Context() = default; // Creates a context object from a map of keys and identifiers, this will // hold a shared_ptr to the head of the DataList linked list template Context(const T &keys_and_values) noexcept : head_{nostd::shared_ptr{new DataList(keys_and_values)}} {} // Creates a context object from a key and value, this will // hold a shared_ptr to the head of the DataList linked list Context(nostd::string_view key, ContextValue value) noexcept : head_{nostd::shared_ptr{new DataList(key, value)}} {} // Accepts a new iterable and then returns a new context that // contains the new key and value data. It attaches the // exisiting list to the end of the new list. template Context SetValues(T &values) noexcept { Context context = Context(values); nostd::shared_ptr last = context.head_; while (last->next_ != nullptr) { last = last->next_; } last->next_ = head_; return context; } // Accepts a new iterable and then returns a new context that // contains the new key and value data. It attaches the // exisiting list to the end of the new list. Context SetValue(nostd::string_view key, ContextValue value) noexcept { Context context = Context(key, value); context.head_->next_ = head_; return context; } // Returns the value associated with the passed in key. context::ContextValue GetValue(const nostd::string_view key) const noexcept { for (DataList *data = head_.get(); data != nullptr; data = data->next_.get()) { if (key.size() == data->key_length_) { if (std::memcmp(key.data(), data->key_, data->key_length_) == 0) { return data->value_; } } } return ContextValue{}; } // Checks for key and returns true if found bool HasKey(const nostd::string_view key) const noexcept { return !nostd::holds_alternative(GetValue(key)); } bool operator==(const Context &other) const noexcept { return (head_ == other.head_); } private: // A linked list to contain the keys and values of this context node struct DataList { char *key_ = nullptr; nostd::shared_ptr next_{nullptr}; size_t key_length_ = 0UL; ContextValue value_; DataList() = default; // Builds a data list off of a key and value iterable and returns the head template DataList(const T &keys_and_vals) { bool first = true; auto *node = this; for (auto &iter : keys_and_vals) { if (first) { *node = DataList(iter.first, iter.second); first = false; } else { node->next_ = nostd::shared_ptr(new DataList(iter.first, iter.second)); node = node->next_.get(); } } } // Builds a data list with just a key and value, so it will just be the head // and returns that head. DataList(nostd::string_view key, const ContextValue &value) { key_ = new char[key.size()]; key_length_ = key.size(); std::memcpy(key_, key.data(), key.size() * sizeof(char)); next_ = nostd::shared_ptr{nullptr}; value_ = value; } DataList(const DataList &other) : key_(new char[other.key_length_]), next_(other.next_), key_length_(other.key_length_), value_(other.value_) { std::memcpy(key_, other.key_, other.key_length_ * sizeof(char)); } DataList &operator=(DataList &&other) noexcept { key_length_ = other.key_length_; value_ = std::move(other.value_); next_ = std::move(other.next_); key_ = other.key_; other.key_ = nullptr; return *this; } ~DataList() { if (key_ != nullptr) { delete[] key_; } } }; // Head of the list which holds the keys and values of this context nostd::shared_ptr head_; }; } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/context_value.h000066400000000000000000000016241474412371400270750ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace baggage { class Baggage; } // namespace baggage namespace trace { class Span; class SpanContext; } // namespace trace namespace context { using ContextValue = nostd::variant, nostd::shared_ptr, nostd::shared_ptr>; } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/propagation/000077500000000000000000000000001474412371400263645ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/propagation/composite_propagator.h000066400000000000000000000046621474412371400330050ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { namespace propagation { class CompositePropagator : public TextMapPropagator { public: CompositePropagator(std::vector> propagators) : propagators_(std::move(propagators)) {} /** * Run each of the configured propagators with the given context and carrier. * Propagators are run in the order they are configured, so if multiple * propagators write the same carrier key, the propagator later in the list * will "win". * * @param carrier Carrier into which context will be injected * @param context Context to inject * */ void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override { for (auto &p : propagators_) { p->Inject(carrier, context); } } /** * Run each of the configured propagators with the given context and carrier. * Propagators are run in the order they are configured, so if multiple * propagators write the same context key, the propagator later in the list * will "win". * * @param carrier Carrier from which to extract context * @param context Context to add values to */ context::Context Extract(const TextMapCarrier &carrier, context::Context &context) noexcept override { auto first = true; context::Context tmp_context; for (auto &p : propagators_) { if (first) { tmp_context = p->Extract(carrier, context); first = false; } else { tmp_context = p->Extract(carrier, tmp_context); } } return propagators_.size() ? tmp_context : context; } /** * Invoke callback with fields set to carrier by `inject` method for all the * configured propagators * Returns true if all invocation return true */ bool Fields(nostd::function_ref callback) const noexcept override { bool status = true; for (auto &p : propagators_) { status = status && p->Fields(callback); } return status; } private: std::vector> propagators_; }; } // namespace propagation } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/propagation/global_propagator.h000066400000000000000000000026011474412371400322320ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/context/propagation/noop_propagator.h" #include "opentelemetry/common/macros.h" #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { namespace propagation { class TextMapPropagator; /* Stores the singleton TextMapPropagator */ class OPENTELEMETRY_EXPORT GlobalTextMapPropagator { public: static nostd::shared_ptr GetGlobalPropagator() noexcept { std::lock_guard guard(GetLock()); return nostd::shared_ptr(GetPropagator()); } static void SetGlobalPropagator(const nostd::shared_ptr &prop) noexcept { std::lock_guard guard(GetLock()); GetPropagator() = prop; } private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetPropagator() noexcept { static nostd::shared_ptr propagator(new NoOpPropagator()); return propagator; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { static common::SpinLockMutex lock; return lock; } }; } // namespace propagation } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/propagation/noop_propagator.h000066400000000000000000000017361474412371400317550ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { namespace propagation { /** * No-op implementation TextMapPropagator */ class NoOpPropagator : public TextMapPropagator { public: /** Noop extract function does nothing and returns the input context */ context::Context Extract(const TextMapCarrier & /*carrier*/, context::Context &context) noexcept override { return context; } /** Noop inject function does nothing */ void Inject(TextMapCarrier & /*carrier*/, const context::Context & /* context */) noexcept override {} bool Fields(nostd::function_ref /* callback */) const noexcept override { return true; } }; } // namespace propagation } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/propagation/text_map_propagator.h000066400000000000000000000037701474412371400326230ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/function_ref.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { namespace propagation { // TextMapCarrier is the storage medium used by TextMapPropagator. class TextMapCarrier { public: // returns the value associated with the passed key. virtual nostd::string_view Get(nostd::string_view key) const noexcept = 0; // stores the key-value pair. virtual void Set(nostd::string_view key, nostd::string_view value) noexcept = 0; /* list of all the keys in the carrier. By default, it returns true without invoking callback */ virtual bool Keys(nostd::function_ref /* callback */) const noexcept { return true; } virtual ~TextMapCarrier() = default; }; // The TextMapPropagator class provides an interface that enables extracting and injecting // context into carriers that travel in-band across process boundaries. HTTP frameworks and clients // can integrate with TextMapPropagator by providing the object containing the // headers, and a getter and setter function for the extraction and // injection of values, respectively. class TextMapPropagator { public: // Returns the context that is stored in the carrier with the TextMapCarrier as extractor. virtual context::Context Extract(const TextMapCarrier &carrier, context::Context &context) noexcept = 0; // Sets the context for carrier with self defined rules. virtual void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept = 0; // Gets the fields set in the carrier by the `inject` method virtual bool Fields(nostd::function_ref callback) const noexcept = 0; virtual ~TextMapPropagator() = default; }; } // namespace propagation } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/context/runtime_context.h000066400000000000000000000226251474412371400274500ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/common/macros.h" #include "opentelemetry/context/context.h" #include "opentelemetry/context/context_value.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace context { // The Token object provides is returned when attaching objects to the // RuntimeContext object and is associated with a context object, and // can be provided to the RuntimeContext Detach method to remove the // associated context from the RuntimeContext. class Token { public: bool operator==(const Context &other) const noexcept { return context_ == other; } ~Token() noexcept; private: friend class RuntimeContextStorage; // A constructor that sets the token's Context object to the // one that was passed in. Token(const Context &context) : context_(context) {} const Context context_; }; /** * RuntimeContextStorage is used by RuntimeContext to store Context frames. * * Custom context management strategies can be implemented by deriving from * this class and passing an initialized RuntimeContextStorage object to * RuntimeContext::SetRuntimeContextStorage. */ class OPENTELEMETRY_EXPORT RuntimeContextStorage { public: /** * Return the current context. * @return the current context */ virtual Context GetCurrent() noexcept = 0; /** * Set the current context. * @param the new current context * @return a token for the new current context. This never returns a nullptr. */ virtual nostd::unique_ptr Attach(const Context &context) noexcept = 0; /** * Detach the context related to the given token. * @param token a token related to a context * @return true if the context could be detached */ virtual bool Detach(Token &token) noexcept = 0; virtual ~RuntimeContextStorage() {} protected: nostd::unique_ptr CreateToken(const Context &context) noexcept { return nostd::unique_ptr(new Token(context)); } }; /** * Construct and return the default RuntimeContextStorage * @return a ThreadLocalContextStorage */ static RuntimeContextStorage *GetDefaultStorage() noexcept; // Provides a wrapper for propagating the context object globally. // // By default, a thread-local runtime context storage is used. class OPENTELEMETRY_EXPORT RuntimeContext { public: // Return the current context. static Context GetCurrent() noexcept { return GetRuntimeContextStorage()->GetCurrent(); } // Sets the current 'Context' object. Returns a token // that can be used to reset to the previous Context. static nostd::unique_ptr Attach(const Context &context) noexcept { return GetRuntimeContextStorage()->Attach(context); } // Resets the context to a previous value stored in the // passed in token. Returns true if successful, false otherwise static bool Detach(Token &token) noexcept { return GetRuntimeContextStorage()->Detach(token); } // Sets the Key and Value into the passed in context or if a context is not // passed in, the RuntimeContext. // Should be used to SetValues to the current RuntimeContext, is essentially // equivalent to RuntimeContext::GetCurrent().SetValue(key,value). Keep in // mind that the current RuntimeContext will not be changed, and the new // context will be returned. static Context SetValue(nostd::string_view key, const ContextValue &value, Context *context = nullptr) noexcept { Context temp_context; if (context == nullptr) { temp_context = GetCurrent(); } else { temp_context = *context; } return temp_context.SetValue(key, value); } // Returns the value associated with the passed in key and either the // passed in context* or the runtime context if a context is not passed in. // Should be used to get values from the current RuntimeContext, is // essentially equivalent to RuntimeContext::GetCurrent().GetValue(key). static ContextValue GetValue(nostd::string_view key, Context *context = nullptr) noexcept { Context temp_context; if (context == nullptr) { temp_context = GetCurrent(); } else { temp_context = *context; } return temp_context.GetValue(key); } /** * Provide a custom runtime context storage. * * This provides a possibility to override the default thread-local runtime * context storage. This has to be set before any spans are created by the * application, otherwise the behavior is undefined. * * @param storage a custom runtime context storage */ static void SetRuntimeContextStorage( const nostd::shared_ptr &storage) noexcept { GetStorage() = storage; } /** * Provide a pointer to const runtime context storage. * * The returned pointer can only be used for extending the lifetime of the runtime context * storage. * */ static nostd::shared_ptr GetConstRuntimeContextStorage() noexcept { return GetRuntimeContextStorage(); } private: static nostd::shared_ptr GetRuntimeContextStorage() noexcept { return GetStorage(); } OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetStorage() noexcept { static nostd::shared_ptr context(GetDefaultStorage()); return context; } }; inline Token::~Token() noexcept { context::RuntimeContext::Detach(*this); } // The ThreadLocalContextStorage class is a derived class from // RuntimeContextStorage and provides a wrapper for propagating context through // cpp thread locally. This file must be included to use the RuntimeContext // class if another implementation has not been registered. class ThreadLocalContextStorage : public RuntimeContextStorage { public: ThreadLocalContextStorage() noexcept = default; // Return the current context. Context GetCurrent() noexcept override { return GetStack().Top(); } // Resets the context to the value previous to the passed in token. This will // also detach all child contexts of the passed in token. // Returns true if successful, false otherwise. bool Detach(Token &token) noexcept override { // In most cases, the context to be detached is on the top of the stack. if (token == GetStack().Top()) { GetStack().Pop(); return true; } if (!GetStack().Contains(token)) { return false; } while (!(token == GetStack().Top())) { GetStack().Pop(); } GetStack().Pop(); return true; } // Sets the current 'Context' object. Returns a token // that can be used to reset to the previous Context. nostd::unique_ptr Attach(const Context &context) noexcept override { GetStack().Push(context); return CreateToken(context); } private: // A nested class to store the attached contexts in a stack. class Stack { friend class ThreadLocalContextStorage; Stack() noexcept : size_(0), capacity_(0), base_(nullptr) {} // Pops the top Context off the stack. void Pop() noexcept { if (size_ == 0) { return; } // Store empty Context before decrementing `size`, to ensure // the shared_ptr object (if stored in prev context object ) are released. // The stack is not resized, and the unused memory would be reutilised // for subsequent context storage. base_[size_ - 1] = Context(); size_ -= 1; } bool Contains(const Token &token) const noexcept { for (size_t pos = size_; pos > 0; --pos) { if (token == base_[pos - 1]) { return true; } } return false; } // Returns the Context at the top of the stack. Context Top() const noexcept { if (size_ == 0) { return Context(); } return base_[size_ - 1]; } // Pushes the passed in context pointer to the top of the stack // and resizes if necessary. void Push(const Context &context) noexcept { size_++; if (size_ > capacity_) { Resize(size_ * 2); } base_[size_ - 1] = context; } // Reallocates the storage array to the pass in new capacity size. void Resize(size_t new_capacity) noexcept { size_t old_size = size_ - 1; if (new_capacity == 0) { new_capacity = 2; } Context *temp = new Context[new_capacity]; if (base_ != nullptr) { // vs2015 does not like this construct considering it unsafe: // - std::copy(base_, base_ + old_size, temp); // Ref. // https://stackoverflow.com/questions/12270224/xutility2227-warning-c4996-std-copy-impl for (size_t i = 0; i < (std::min)(old_size, new_capacity); i++) { temp[i] = base_[i]; } delete[] base_; } base_ = temp; capacity_ = new_capacity; } ~Stack() noexcept { delete[] base_; } size_t size_; size_t capacity_; Context *base_; }; OPENTELEMETRY_API_SINGLETON Stack &GetStack() { static thread_local Stack stack_ = Stack(); return stack_; } }; static RuntimeContextStorage *GetDefaultStorage() noexcept { return new ThreadLocalContextStorage(); } } // namespace context OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/detail/000077500000000000000000000000001474412371400236175ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/detail/preprocessor.h000066400000000000000000000013631474412371400265210ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 // NOTE - code within detail namespace implements internal details, and not part // of the public interface. #pragma once #define OPENTELEMETRY_STRINGIFY(S) OPENTELEMETRY_STRINGIFY_(S) #define OPENTELEMETRY_STRINGIFY_(S) #S #define OPENTELEMETRY_CONCAT(A, B) OPENTELEMETRY_CONCAT_(A, B) #define OPENTELEMETRY_CONCAT_(A, B) A##B // Import the C++20 feature-test macros #ifdef __has_include # if __has_include() # include # endif #elif defined(_MSC_VER) && ((defined(__cplusplus) && __cplusplus >= 202002L) || \ (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)) # if _MSC_VER >= 1922 # include # endif #endif opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/000077500000000000000000000000001474412371400233215ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/event_id.h000066400000000000000000000014351474412371400252720ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { /** * EventId class which acts the Id of the event with an optional name. */ class EventId { public: EventId(int64_t id, nostd::string_view name) noexcept : id_{id}, name_{nostd::unique_ptr{new char[name.length() + 1]}} { std::copy(name.begin(), name.end(), name_.get()); name_.get()[name.length()] = 0; } EventId(int64_t id) noexcept : id_{id}, name_{nullptr} {} public: int64_t id_; nostd::unique_ptr name_; }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/event_logger.h000066400000000000000000000051501474412371400261530ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_type_traits.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { /** * Handles event log record creation. **/ class EventLogger { public: virtual ~EventLogger() = default; /* Returns the name of the logger */ virtual const nostd::string_view GetName() noexcept = 0; /* Returns the delegate logger of this event logger */ virtual nostd::shared_ptr GetDelegateLogger() noexcept = 0; /** * Emit a event Log Record object * * @param event_name Event name * @param log_record Log record */ virtual void EmitEvent(nostd::string_view event_name, nostd::unique_ptr &&log_record) noexcept = 0; /** * Emit a event Log Record object with arguments * * @param event_name Event name * @tparam args Arguments which can be used to set data of log record by type. * Severity -> severity, severity_text * string_view -> body * AttributeValue -> body * SpanContext -> span_id,tace_id and trace_flags * SpanId -> span_id * TraceId -> tace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void EmitEvent(nostd::string_view event_name, ArgumentType &&...args) { nostd::shared_ptr delegate_logger = GetDelegateLogger(); if (!delegate_logger) { return; } nostd::unique_ptr log_record = delegate_logger->CreateLogRecord(); IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( log_record.get(), std::forward(args))...); EmitEvent(event_name, std::move(log_record)); } private: template void IgnoreTraitResult(ValueType &&...) {} }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/event_logger_provider.h000066400000000000000000000012761474412371400300720ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { class EventLogger; class Logger; /** * Creates new EventLogger instances. */ class EventLoggerProvider { public: virtual ~EventLoggerProvider() = default; /** * Creates a named EventLogger instance. * */ virtual nostd::shared_ptr CreateEventLogger( nostd::shared_ptr delegate_logger, nostd::string_view event_domain) noexcept = 0; }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/log_record.h000066400000000000000000000044441474412371400256170ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { class SpanId; class TraceId; class TraceFlags; } // namespace trace namespace logs { enum class Severity : uint8_t; /** * Maintains a representation of a log in a format that can be processed by a recorder. * * This class is thread-compatible. */ class LogRecord { public: virtual ~LogRecord() = default; /** * Set the timestamp for this log. * @param timestamp the timestamp to set */ virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0; /** * Set the observed timestamp for this log. * @param timestamp the timestamp to set */ virtual void SetObservedTimestamp(common::SystemTimestamp timestamp) noexcept = 0; /** * Set the severity for this log. * @param severity the severity of the event */ virtual void SetSeverity(logs::Severity severity) noexcept = 0; /** * Set body field for this log. * @param message the body to set */ virtual void SetBody(const common::AttributeValue &message) noexcept = 0; /** * Set an attribute of a log. * @param key the name of the attribute * @param value the attribute value */ virtual void SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept = 0; /** * Set the Event Id. * @param id The event id to set * @param name Optional event name to set */ // TODO: mark this as pure virtual once all exporters have been updated virtual void SetEventId(int64_t id, nostd::string_view name = {}) noexcept = 0; /** * Set the trace id for this log. * @param trace_id the trace id to set */ virtual void SetTraceId(const trace::TraceId &trace_id) noexcept = 0; /** * Set the span id for this log. * @param span_id the span id to set */ virtual void SetSpanId(const trace::SpanId &span_id) noexcept = 0; /** * Inject trace_flags for this log. * @param trace_flags the trace flags to set */ virtual void SetTraceFlags(const trace::TraceFlags &trace_flags) noexcept = 0; }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/logger.h000066400000000000000000000425561474412371400247650ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/logs/logger_type_traits.h" #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { class KeyValueIterable; } // namespace common namespace logs { class EventId; class LogRecord; /** * Handles log record creation. **/ class Logger { public: virtual ~Logger() = default; /* Returns the name of the logger */ virtual const nostd::string_view GetName() noexcept = 0; /** * Create a Log Record object * * @return nostd::unique_ptr */ virtual nostd::unique_ptr CreateLogRecord() noexcept = 0; /** * Emit a Log Record object * * @param log_record */ virtual void EmitLogRecord(nostd::unique_ptr &&log_record) noexcept = 0; /** * Emit a Log Record object with arguments * * @param log_record Log record * @tparam args Arguments which can be used to set data of log record by type. * Severity -> severity, severity_text * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void EmitLogRecord(nostd::unique_ptr &&log_record, ArgumentType &&...args) { if (!log_record) { return; } IgnoreTraitResult(detail::LogRecordSetterTrait::type>::Set( log_record.get(), std::forward(args))...); EmitLogRecord(std::move(log_record)); } /** * Emit a Log Record object with arguments * * @tparam args Arguments which can be used to set data of log record by type. * Severity -> severity, severity_text * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void EmitLogRecord(ArgumentType &&...args) { nostd::unique_ptr log_record = CreateLogRecord(); EmitLogRecord(std::move(log_record), std::forward(args)...); } /** * Writes a log with a severity of trace. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Trace(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kTrace, std::forward(args)...); } /** * Writes a log with a severity of debug. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Debug(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kDebug, std::forward(args)...); } /** * Writes a log with a severity of info. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Info(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kInfo, std::forward(args)...); } /** * Writes a log with a severity of warn. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Warn(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kWarn, std::forward(args)...); } /** * Writes a log with a severity of error. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Error(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kError, std::forward(args)...); } /** * Writes a log with a severity of fatal. * @tparam args Arguments which can be used to set data of log record by type. * string_view -> body * AttributeValue -> body * SpanContext -> span_id,trace_id and trace_flags * SpanId -> span_id * TraceId -> trace_id * TraceFlags -> trace_flags * SystemTimestamp -> timestamp * system_clock::time_point -> timestamp * KeyValueIterable -> attributes * Key value iterable container -> attributes * span> -> attributes(return type of MakeAttributes) */ template void Fatal(ArgumentType &&...args) noexcept { static_assert( !detail::LogRecordHasType::type...>::value, "Severity is already set."); this->EmitLogRecord(Severity::kFatal, std::forward(args)...); } // // OpenTelemetry C++ user-facing Logs API // inline bool Enabled(Severity severity, const EventId &event_id) const noexcept { if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity)) { return false; } return EnabledImplementation(severity, event_id); } inline bool Enabled(Severity severity, int64_t event_id) const noexcept { if OPENTELEMETRY_LIKELY_CONDITION (!Enabled(severity)) { return false; } return EnabledImplementation(severity, event_id); } inline bool Enabled(Severity severity) const noexcept { return static_cast(severity) >= OPENTELEMETRY_ATOMIC_READ_8(&minimum_severity_); } /** * Log an event * * @severity severity of the log * @event_id event identifier of the log * @format an utf-8 string following https://messagetemplates.org/ * @attributes key value pairs of the log */ virtual void Log(Severity severity, const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->EmitLogRecord(severity, event_id, format, attributes); } virtual void Log(Severity severity, int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->EmitLogRecord(severity, EventId{event_id}, format, attributes); } virtual void Log(Severity severity, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->EmitLogRecord(severity, format, attributes); } virtual void Log(Severity severity, nostd::string_view message) noexcept { this->EmitLogRecord(severity, message); } // Convenient wrappers based on virtual methods Log(). // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber inline void Trace(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kTrace, event_id, format, attributes); } inline void Trace(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kTrace, EventId{event_id}, format, attributes); } inline void Trace(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kTrace, format, attributes); } inline void Trace(nostd::string_view message) noexcept { this->Log(Severity::kTrace, message); } inline void Debug(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kDebug, event_id, format, attributes); } inline void Debug(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kDebug, EventId{event_id}, format, attributes); } inline void Debug(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kDebug, format, attributes); } inline void Debug(nostd::string_view message) noexcept { this->Log(Severity::kDebug, message); } inline void Info(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kInfo, event_id, format, attributes); } inline void Info(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kInfo, EventId{event_id}, format, attributes); } inline void Info(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kInfo, format, attributes); } inline void Info(nostd::string_view message) noexcept { this->Log(Severity::kInfo, message); } inline void Warn(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kWarn, event_id, format, attributes); } inline void Warn(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kWarn, EventId{event_id}, format, attributes); } inline void Warn(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kWarn, format, attributes); } inline void Warn(nostd::string_view message) noexcept { this->Log(Severity::kWarn, message); } inline void Error(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kError, event_id, format, attributes); } inline void Error(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kError, EventId{event_id}, format, attributes); } inline void Error(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kError, format, attributes); } inline void Error(nostd::string_view message) noexcept { this->Log(Severity::kError, message); } inline void Fatal(const EventId &event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kFatal, event_id, format, attributes); } inline void Fatal(int64_t event_id, nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kFatal, EventId{event_id}, format, attributes); } inline void Fatal(nostd::string_view format, const common::KeyValueIterable &attributes) noexcept { this->Log(Severity::kFatal, format, attributes); } inline void Fatal(nostd::string_view message) noexcept { this->Log(Severity::kFatal, message); } // // End of OpenTelemetry C++ user-facing Log API. // protected: // TODO: discuss with community about naming for internal methods. virtual bool EnabledImplementation(Severity /*severity*/, const EventId & /*event_id*/) const noexcept { return false; } virtual bool EnabledImplementation(Severity /*severity*/, int64_t /*event_id*/) const noexcept { return false; } void SetMinimumSeverity(uint8_t severity_or_max) noexcept { OPENTELEMETRY_ATOMIC_WRITE_8(&minimum_severity_, severity_or_max); } private: template void IgnoreTraitResult(ValueType &&...) {} // // minimum_severity_ can be updated concurrently by multiple threads/cores, so race condition on // read/write should be handled. And std::atomic can not be used here because it is not ABI // compatible for OpenTelemetry C++ API. // mutable uint8_t minimum_severity_{kMaxSeverity}; }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/logger_provider.h000066400000000000000000000045701474412371400266710ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { class Logger; /** * Creates new Logger instances. */ class OPENTELEMETRY_EXPORT LoggerProvider { public: virtual ~LoggerProvider() = default; /** * Gets or creates a named Logger instance. * * Optionally a version can be passed to create a named and versioned Logger * instance. * * Optionally a configuration file name can be passed to create a configuration for * the Logger instance. * */ virtual nostd::shared_ptr GetLogger( nostd::string_view logger_name, nostd::string_view library_name = "", nostd::string_view library_version = "", nostd::string_view schema_url = "", const common::KeyValueIterable &attributes = common::NoopKeyValueIterable()) = 0; nostd::shared_ptr GetLogger( nostd::string_view logger_name, nostd::string_view library_name, nostd::string_view library_version, nostd::string_view schema_url, std::initializer_list> attributes) { return GetLogger(logger_name, library_name, library_version, schema_url, nostd::span>{ attributes.begin(), attributes.end()}); } template ::value> * = nullptr> nostd::shared_ptr GetLogger(nostd::string_view logger_name, nostd::string_view library_name, nostd::string_view library_version, nostd::string_view schema_url, const T &attributes) { return GetLogger(logger_name, library_name, library_version, schema_url, common::KeyValueIterableView(attributes)); } }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/logger_type_traits.h000066400000000000000000000131021474412371400273750ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/timestamp.h" #include "opentelemetry/logs/event_id.h" #include "opentelemetry/logs/log_record.h" #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/trace/span_context.h" #include "opentelemetry/trace/span_id.h" #include "opentelemetry/trace/trace_flags.h" #include "opentelemetry/trace/trace_id.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { namespace detail { template struct LogRecordSetterTrait; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetSeverity(std::forward(arg)); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetEventId(arg.id_, nostd::string_view{arg.name_.get()}); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetSpanId(arg.span_id()); log_record->SetTraceId(arg.trace_id()); log_record->SetTraceFlags(arg.trace_flags()); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetSpanId(std::forward(arg)); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetTraceId(std::forward(arg)); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetTraceFlags(std::forward(arg)); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetTimestamp(std::forward(arg)); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetTimestamp(common::SystemTimestamp(std::forward(arg))); return log_record; } }; template <> struct LogRecordSetterTrait { template inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { arg.ForEachKeyValue( [&log_record](nostd::string_view key, common::AttributeValue value) noexcept { log_record->SetAttribute(key, value); return true; }); return log_record; } }; template struct LogRecordSetterTrait { static_assert(!std::is_same, ValueType>::value && !std::is_same, ValueType>::value, "unique_ptr is not allowed, please use std::move()"); template ::value || std::is_convertible::value, void> * = nullptr> inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { log_record->SetBody(std::forward(arg)); return log_record; } template ::value, bool> * = nullptr> inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { return LogRecordSetterTrait::Set(log_record, std::forward(arg)); } template ::value, int> * = nullptr> inline static LogRecord *Set(LogRecord *log_record, ArgumentType &&arg) noexcept { for (auto &argv : arg) { log_record->SetAttribute(argv.first, argv.second); } return log_record; } }; template struct LogRecordHasType; template struct LogRecordHasType : public std::false_type {}; template struct LogRecordHasType : public std::conditional::value, std::true_type, LogRecordHasType>::type {}; } // namespace detail } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/noop.h000066400000000000000000000101611474412371400244440ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once // Please refer to provider.h for documentation on how to obtain a Logger object. // // This file is part of the internal implementation of OpenTelemetry. Nothing in this file should be // used directly. Please refer to logger.h for documentation on these interfaces. #include "opentelemetry/logs/event_logger.h" #include "opentelemetry/logs/event_logger_provider.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace common { class KeyValueIterable; } // namespace common namespace logs { /** * No-op implementation of Logger. This class should not be used directly. It should only be * instantiated using a LoggerProvider's GetLogger() call. */ class NoopLogger final : public Logger { public: const nostd::string_view GetName() noexcept override { return "noop logger"; } nostd::unique_ptr CreateLogRecord() noexcept override { /* * Do not return memory shared between threads, * a `new` + `delete` for each noop record can not be avoided, * due to the semantic of unique_ptr. */ return nostd::unique_ptr(new NoopLogRecord()); } using Logger::EmitLogRecord; void EmitLogRecord(nostd::unique_ptr &&) noexcept override {} private: class NoopLogRecord : public LogRecord { public: NoopLogRecord() = default; ~NoopLogRecord() override = default; void SetTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} void SetObservedTimestamp(common::SystemTimestamp /* timestamp */) noexcept override {} void SetSeverity(logs::Severity /* severity */) noexcept override {} void SetBody(const common::AttributeValue & /* message */) noexcept override {} void SetAttribute(nostd::string_view /* key */, const common::AttributeValue & /* value */) noexcept override {} void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override {} void SetTraceId(const trace::TraceId & /* trace_id */) noexcept override {} void SetSpanId(const trace::SpanId & /* span_id */) noexcept override {} void SetTraceFlags(const trace::TraceFlags & /* trace_flags */) noexcept override {} }; }; /** * No-op implementation of a LoggerProvider. */ class NoopLoggerProvider final : public LoggerProvider { public: NoopLoggerProvider() : logger_{nostd::shared_ptr(new NoopLogger())} {} nostd::shared_ptr GetLogger(nostd::string_view /* logger_name */, nostd::string_view /* library_name */, nostd::string_view /* library_version */, nostd::string_view /* schema_url */, const common::KeyValueIterable & /* attributes */) override { return logger_; } private: nostd::shared_ptr logger_; }; class NoopEventLogger final : public EventLogger { public: NoopEventLogger() : logger_{nostd::shared_ptr(new NoopLogger())} {} const nostd::string_view GetName() noexcept override { return "noop event logger"; } nostd::shared_ptr GetDelegateLogger() noexcept override { return logger_; } void EmitEvent(nostd::string_view, nostd::unique_ptr &&) noexcept override {} private: nostd::shared_ptr logger_; }; /** * No-op implementation of a EventLoggerProvider. */ class NoopEventLoggerProvider final : public EventLoggerProvider { public: NoopEventLoggerProvider() : event_logger_{nostd::shared_ptr(new NoopEventLogger())} {} nostd::shared_ptr CreateEventLogger( nostd::shared_ptr /*delegate_logger*/, nostd::string_view /*event_domain*/) noexcept override { return event_logger_; } private: nostd::shared_ptr event_logger_; }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/provider.h000066400000000000000000000045631474412371400253340ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/common/macros.h" #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/logs/noop.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { class EventLoggerProvider; class LoggerProvider; /** * Stores the singleton global LoggerProvider. */ class OPENTELEMETRY_EXPORT Provider { public: /** * Returns the singleton LoggerProvider. * * By default, a no-op LoggerProvider is returned. This will never return a * nullptr LoggerProvider. */ static nostd::shared_ptr GetLoggerProvider() noexcept { std::lock_guard guard(GetLock()); return nostd::shared_ptr(GetProvider()); } /** * Changes the singleton LoggerProvider. */ static void SetLoggerProvider(const nostd::shared_ptr &tp) noexcept { std::lock_guard guard(GetLock()); GetProvider() = tp; } /** * Returns the singleton EventLoggerProvider. * * By default, a no-op EventLoggerProvider is returned. This will never return a * nullptr EventLoggerProvider. */ static nostd::shared_ptr GetEventLoggerProvider() noexcept { std::lock_guard guard(GetLock()); return nostd::shared_ptr(GetEventProvider()); } /** * Changes the singleton EventLoggerProvider. */ static void SetEventLoggerProvider(const nostd::shared_ptr &tp) noexcept { std::lock_guard guard(GetLock()); GetEventProvider() = tp; } private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept { static nostd::shared_ptr provider(new NoopLoggerProvider); return provider; } OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr & GetEventProvider() noexcept { static nostd::shared_ptr provider(new NoopEventLoggerProvider); return provider; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { static common::SpinLockMutex lock; return lock; } }; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/logs/severity.h000066400000000000000000000032401474412371400253430ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace logs { /** * Severity Levels assigned to log events, based on Log Data Model, * with the addition of kInvalid (mapped to a severity number of 0). * * See * https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-severitynumber */ enum class Severity : uint8_t { kInvalid = 0, kTrace = 1, kTrace2 = 2, kTrace3 = 3, kTrace4 = 4, kDebug = 5, kDebug2 = 6, kDebug3 = 7, kDebug4 = 8, kInfo = 9, kInfo2 = 10, kInfo3 = 11, kInfo4 = 12, kWarn = 13, kWarn2 = 14, kWarn3 = 15, kWarn4 = 16, kError = 17, kError2 = 18, kError3 = 19, kError4 = 20, kFatal = 21, kFatal2 = 22, kFatal3 = 23, kFatal4 = 24 }; const uint8_t kMaxSeverity = 255; /** * Mapping of the severity enum above, to a severity text string (in all caps). * This severity text can be printed out by exporters. Capital letters follow the * spec naming convention. * * Included to follow the specification's recommendation to print both * severity number and text in each log record. */ const nostd::string_view SeverityNumToText[25] = { "INVALID", "TRACE", "TRACE2", "TRACE3", "TRACE4", "DEBUG", "DEBUG2", "DEBUG3", "DEBUG4", "INFO", "INFO2", "INFO3", "INFO4", "WARN", "WARN2", "WARN3", "WARN4", "ERROR", "ERROR2", "ERROR3", "ERROR4", "FATAL", "FATAL2", "FATAL3", "FATAL4"}; } // namespace logs OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/000077500000000000000000000000001474412371400240235ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/async_instruments.h000066400000000000000000000015201474412371400277620ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/metrics/observer_result.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { using ObservableCallbackPtr = void (*)(ObserverResult, void *); class ObservableInstrument { public: ObservableInstrument() = default; virtual ~ObservableInstrument() = default; /** * Sets up a function that will be called whenever a metric collection is initiated. */ virtual void AddCallback(ObservableCallbackPtr, void *state) noexcept = 0; /** * Remove a function that was configured to be called whenever a metric collection is initiated. */ virtual void RemoveCallback(ObservableCallbackPtr, void *state) noexcept = 0; }; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/meter.h000066400000000000000000000146521474412371400253200ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/unique_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { template class Counter; template class Histogram; template class UpDownCounter; template class Gauge; class ObservableInstrument; /** * Handles instrument creation and provides a facility for batch recording. * * This class provides methods to create new metric instruments, record a * batch of values to a specified set of instruments, and collect * measurements from all instruments. * */ class Meter { public: virtual ~Meter() = default; /** * Creates a Counter with the passed characteristics and returns a unique_ptr to that Counter. * * @param name the name of the new Counter. * @param description a brief description of what the Counter is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. * @return a shared pointer to the created Counter. */ virtual nostd::unique_ptr> CreateUInt64Counter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::unique_ptr> CreateDoubleCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; /** * Creates a Asynchronous (Observable) counter with the passed characteristics and returns a * shared_ptr to that Observable Counter * * @param name the name of the new Observable Counter. * @param description a brief description of what the Observable Counter is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. */ virtual nostd::shared_ptr CreateInt64ObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::shared_ptr CreateDoubleObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; /** * Creates a Histogram with the passed characteristics and returns a unique_ptr to that Histogram. * * @param name the name of the new Histogram. * @param description a brief description of what the Histogram is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. * @return a shared pointer to the created Histogram. */ virtual nostd::unique_ptr> CreateUInt64Histogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::unique_ptr> CreateDoubleHistogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 /** * Creates a Gauge with the passed characteristics and returns a unique_ptr to that Gauge. * * @param name the name of the new Gauge. * @param description a brief description of what the Gauge is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. * @return a unique pointer to the created Gauge. */ virtual nostd::unique_ptr> CreateInt64Gauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::unique_ptr> CreateDoubleGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; #endif /** * Creates a Asynchronous (Observable) Gauge with the passed characteristics and returns a * shared_ptr to that Observable Gauge * * @param name the name of the new Observable Gauge. * @param description a brief description of what the Observable Gauge is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. */ virtual nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::shared_ptr CreateDoubleObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; /** * Creates an UpDownCounter with the passed characteristics and returns a unique_ptr to that * UpDownCounter. * * @param name the name of the new UpDownCounter. * @param description a brief description of what the UpDownCounter is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. * @return a shared pointer to the created UpDownCounter. */ virtual nostd::unique_ptr> CreateInt64UpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::unique_ptr> CreateDoubleUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; /** * Creates a Asynchronous (Observable) UpDownCounter with the passed characteristics and returns * a shared_ptr to that Observable UpDownCounter * * @param name the name of the new Observable UpDownCounter. * @param description a brief description of what the Observable UpDownCounter is used for. * @param unit the unit of metric values following https://unitsofmeasure.org/ucum.html. */ virtual nostd::shared_ptr CreateInt64ObservableUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; virtual nostd::shared_ptr CreateDoubleObservableUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept = 0; }; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/meter_provider.h000066400000000000000000000115241474412371400272250ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { class Meter; /** * Creates new Meter instances. */ class MeterProvider { public: virtual ~MeterProvider() = default; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 /** * Gets or creates a named Meter instance (ABI). * * @since ABI_VERSION 2 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version * @param[in] schema_url Instrumentation scope schema URL * @param[in] attributes Instrumentation scope attributes (optional, may be nullptr) */ virtual nostd::shared_ptr GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const common::KeyValueIterable *attributes) noexcept = 0; /** * Gets or creates a named Meter instance (API helper). * * @since ABI_VERSION 2 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version, optional * @param[in] schema_url Instrumentation scope schema URL, optional */ nostd::shared_ptr GetMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") { return GetMeter(name, version, schema_url, nullptr); } /** * Gets or creates a named Meter instance (API helper). * * @since ABI_VERSION 2 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version * @param[in] schema_url Instrumentation scope schema URL * @param[in] attributes Instrumentation scope attributes */ nostd::shared_ptr GetMeter( nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, std::initializer_list> attributes) { /* Build a container from std::initializer_list. */ nostd::span> attributes_span{ attributes.begin(), attributes.end()}; /* Build a view on the container. */ common::KeyValueIterableView< nostd::span>> iterable_attributes{attributes_span}; /* Add attributes using the view. */ return GetMeter(name, version, schema_url, &iterable_attributes); } /** * Gets or creates a named Meter instance (API helper). * * @since ABI_VERSION 2 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version * @param[in] schema_url Instrumentation scope schema URL * @param[in] attributes Instrumentation scope attributes container */ template ::value> * = nullptr> nostd::shared_ptr GetMeter(nostd::string_view name, nostd::string_view version, nostd::string_view schema_url, const T &attributes) { /* Build a view on the container. */ common::KeyValueIterableView iterable_attributes(attributes); /* Add attributes using the view. */ return GetMeter(name, version, schema_url, &iterable_attributes); } #else /** * Gets or creates a named Meter instance (ABI) * * @since ABI_VERSION 1 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version, optional * @param[in] schema_url Instrumentation scope schema URL, optional */ virtual nostd::shared_ptr GetMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept = 0; #endif #if OPENTELEMETRY_ABI_VERSION_NO >= 2 /** * Remove a named Meter instance (ABI). * * This API is experimental, see * https://github.com/open-telemetry/opentelemetry-specification/issues/2232 * * @since ABI_VERSION 2 * * @param[in] name Meter instrumentation scope * @param[in] version Instrumentation scope version, optional * @param[in] schema_url Instrumentation scope schema URL, optional */ virtual void RemoveMeter(nostd::string_view name, nostd::string_view version = "", nostd::string_view schema_url = "") noexcept = 0; #endif }; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/noop.h000066400000000000000000000224061474412371400251530ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/metrics/async_instruments.h" #include "opentelemetry/metrics/meter.h" #include "opentelemetry/metrics/meter_provider.h" #include "opentelemetry/metrics/observer_result.h" #include "opentelemetry/metrics/sync_instruments.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { template class NoopCounter : public Counter { public: NoopCounter(nostd::string_view /* name */, nostd::string_view /* description */, nostd::string_view /* unit */) noexcept {} void Add(T /* value */) noexcept override {} void Add(T /* value */, const context::Context & /* context */) noexcept override {} void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} void Add(T /* value */, const common::KeyValueIterable & /* attributes */, const context::Context & /* context */) noexcept override {} }; template class NoopHistogram : public Histogram { public: NoopHistogram(nostd::string_view /* name */, nostd::string_view /* description */, nostd::string_view /* unit */) noexcept {} void Record(T /* value */, const context::Context & /* context */) noexcept override {} void Record(T /* value */, const common::KeyValueIterable & /* attributes */, const context::Context & /* context */) noexcept override {} #if OPENTELEMETRY_ABI_VERSION_NO >= 2 void Record(T /*value*/, const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override {} void Record(T /*value*/) noexcept override {} #endif }; template class NoopUpDownCounter : public UpDownCounter { public: NoopUpDownCounter(nostd::string_view /* name */, nostd::string_view /* description */, nostd::string_view /* unit */) noexcept {} ~NoopUpDownCounter() override = default; void Add(T /* value */) noexcept override {} void Add(T /* value */, const context::Context & /* context */) noexcept override {} void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} void Add(T /* value */, const common::KeyValueIterable & /* attributes */, const context::Context & /* context */) noexcept override {} }; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 template class NoopGauge : public Gauge { public: NoopGauge(nostd::string_view /* name */, nostd::string_view /* description */, nostd::string_view /* unit */) noexcept {} ~NoopGauge() override = default; void Record(T /* value */) noexcept override {} void Record(T /* value */, const context::Context & /* context */) noexcept override {} void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {} void Record(T /* value */, const common::KeyValueIterable & /* attributes */, const context::Context & /* context */) noexcept override {} }; #endif class NoopObservableInstrument : public ObservableInstrument { public: NoopObservableInstrument(nostd::string_view /* name */, nostd::string_view /* description */, nostd::string_view /* unit */) noexcept {} void AddCallback(ObservableCallbackPtr, void * /* state */) noexcept override {} void RemoveCallback(ObservableCallbackPtr, void * /* state */) noexcept override {} }; /** * No-op implementation of Meter. */ class NoopMeter final : public Meter { public: nostd::unique_ptr> CreateUInt64Counter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{new NoopCounter(name, description, unit)}; } nostd::unique_ptr> CreateDoubleCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{new NoopCounter(name, description, unit)}; } nostd::shared_ptr CreateInt64ObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } nostd::shared_ptr CreateDoubleObservableCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } nostd::unique_ptr> CreateUInt64Histogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{ new NoopHistogram(name, description, unit)}; } nostd::unique_ptr> CreateDoubleHistogram( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{new NoopHistogram(name, description, unit)}; } #if OPENTELEMETRY_ABI_VERSION_NO >= 2 nostd::unique_ptr> CreateInt64Gauge(nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; } nostd::unique_ptr> CreateDoubleGauge(nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{new NoopGauge(name, description, unit)}; } #endif nostd::shared_ptr CreateInt64ObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } nostd::shared_ptr CreateDoubleObservableGauge( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } nostd::unique_ptr> CreateInt64UpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{ new NoopUpDownCounter(name, description, unit)}; } nostd::unique_ptr> CreateDoubleUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::unique_ptr>{ new NoopUpDownCounter(name, description, unit)}; } nostd::shared_ptr CreateInt64ObservableUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } nostd::shared_ptr CreateDoubleObservableUpDownCounter( nostd::string_view name, nostd::string_view description = "", nostd::string_view unit = "") noexcept override { return nostd::shared_ptr( new NoopObservableInstrument(name, description, unit)); } }; /** * No-op implementation of a MeterProvider. */ class NoopMeterProvider final : public MeterProvider { public: NoopMeterProvider() : meter_{nostd::shared_ptr(new NoopMeter)} {} #if OPENTELEMETRY_ABI_VERSION_NO >= 2 nostd::shared_ptr GetMeter( nostd::string_view /* name */, nostd::string_view /* version */, nostd::string_view /* schema_url */, const common::KeyValueIterable * /* attributes */) noexcept override { return meter_; } #else nostd::shared_ptr GetMeter(nostd::string_view /* name */, nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override { return meter_; } #endif #if OPENTELEMETRY_ABI_VERSION_NO >= 2 void RemoveMeter(nostd::string_view /* name */, nostd::string_view /* version */, nostd::string_view /* schema_url */) noexcept override {} #endif private: nostd::shared_ptr meter_; }; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/observer_result.h000066400000000000000000000031501474412371400274200ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/nostd/variant.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { /** * ObserverResultT class is necessary for the callback recording asynchronous * instrument use. */ template class ObserverResultT { public: virtual ~ObserverResultT() = default; virtual void Observe(T value) noexcept = 0; virtual void Observe(T value, const common::KeyValueIterable &attributes) noexcept = 0; template ::value> * = nullptr> void Observe(T value, const U &attributes) noexcept { this->Observe(value, common::KeyValueIterableView{attributes}); } void Observe(T value, std::initializer_list> attributes) noexcept { this->Observe(value, nostd::span>{ attributes.begin(), attributes.end()}); } }; using ObserverResult = nostd::variant>, nostd::shared_ptr>>; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/provider.h000066400000000000000000000027071474412371400260340ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/common/macros.h" #include "opentelemetry/common/spin_lock_mutex.h" #include "opentelemetry/metrics/noop.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { class MeterProvider; /** * Stores the singleton global MeterProvider. */ class Provider { public: /** * Returns the singleton MeterProvider. * * By default, a no-op MeterProvider is returned. This will never return a * nullptr MeterProvider. */ static nostd::shared_ptr GetMeterProvider() noexcept { std::lock_guard guard(GetLock()); return nostd::shared_ptr(GetProvider()); } /** * Changes the singleton MeterProvider. */ static void SetMeterProvider(const nostd::shared_ptr &tp) noexcept { std::lock_guard guard(GetLock()); GetProvider() = tp; } private: OPENTELEMETRY_API_SINGLETON static nostd::shared_ptr &GetProvider() noexcept { static nostd::shared_ptr provider(new NoopMeterProvider); return provider; } OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept { static common::SpinLockMutex lock; return lock; } }; } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/metrics/sync_instruments.h000066400000000000000000000250771474412371400276360ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" #include "opentelemetry/context/context.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace metrics { class SynchronousInstrument { public: SynchronousInstrument() = default; virtual ~SynchronousInstrument() = default; }; /* A Counter instrument that adds values. */ template class Counter : public SynchronousInstrument { public: /** * Record a value * * @param value The increment amount. MUST be non-negative. */ virtual void Add(T value) noexcept = 0; /** * Record a value * * @param value The increment amount. MUST be non-negative. * @param context The explicit context to associate with this measurement. */ virtual void Add(T value, const context::Context &context) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The increment amount. MUST be non-negative. * @param attributes A set of attributes to associate with the value. */ virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The increment amount. MUST be non-negative. * @param attributes A set of attributes to associate with the value. * @param context The explicit context to associate with this measurement. */ virtual void Add(T value, const common::KeyValueIterable &attributes, const context::Context &context) noexcept = 0; template ::value> * = nullptr> void Add(T value, const U &attributes) noexcept { this->Add(value, common::KeyValueIterableView{attributes}); } template ::value> * = nullptr> void Add(T value, const U &attributes, const context::Context &context) noexcept { this->Add(value, common::KeyValueIterableView{attributes}, context); } void Add(T value, std::initializer_list> attributes) noexcept { this->Add(value, nostd::span>{ attributes.begin(), attributes.end()}); } void Add(T value, std::initializer_list> attributes, const context::Context &context) noexcept { this->Add(value, nostd::span>{ attributes.begin(), attributes.end()}, context); } }; /** A histogram instrument that records values. */ template class Histogram : public SynchronousInstrument { public: #if OPENTELEMETRY_ABI_VERSION_NO >= 2 /** * @since ABI_VERSION 2 * Records a value. * * @param value The measurement value. MUST be non-negative. */ virtual void Record(T value) noexcept = 0; /** * @since ABI_VERSION 2 * Records a value with a set of attributes. * * @param value The measurement value. MUST be non-negative. * @param attribute A set of attributes to associate with the value. */ virtual void Record(T value, const common::KeyValueIterable &attribute) noexcept = 0; template ::value> * = nullptr> void Record(T value, const U &attributes) noexcept { this->Record(value, common::KeyValueIterableView{attributes}); } void Record(T value, std::initializer_list> attributes) noexcept { this->Record(value, nostd::span>{ attributes.begin(), attributes.end()}); } #endif /** * Records a value. * * @param value The measurement value. MUST be non-negative. * @param context The explicit context to associate with this measurement. */ virtual void Record(T value, const context::Context &context) noexcept = 0; /** * Records a value with a set of attributes. * * @param value The measurement value. MUST be non-negative. * @param attributes A set of attributes to associate with the value.. * @param context The explicit context to associate with this measurement. */ virtual void Record(T value, const common::KeyValueIterable &attributes, const context::Context &context) noexcept = 0; template ::value> * = nullptr> void Record(T value, const U &attributes, const context::Context &context) noexcept { this->Record(value, common::KeyValueIterableView{attributes}, context); } void Record( T value, std::initializer_list> attributes, const context::Context &context) noexcept { this->Record(value, nostd::span>{ attributes.begin(), attributes.end()}, context); } }; /** An up-down-counter instrument that adds or reduce values. */ template class UpDownCounter : public SynchronousInstrument { public: /** * Record a value. * * @param value The increment amount. May be positive, negative or zero. */ virtual void Add(T value) noexcept = 0; /** * Record a value. * * @param value The increment amount. May be positive, negative or zero. * @param context The explicit context to associate with this measurement. */ virtual void Add(T value, const context::Context &context) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The increment amount. May be positive, negative or zero. * @param attributes A set of attributes to associate with the count. */ virtual void Add(T value, const common::KeyValueIterable &attributes) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The increment amount. May be positive, negative or zero. * @param attributes A set of attributes to associate with the count. * @param context The explicit context to associate with this measurement. */ virtual void Add(T value, const common::KeyValueIterable &attributes, const context::Context &context) noexcept = 0; template ::value> * = nullptr> void Add(T value, const U &attributes) noexcept { this->Add(value, common::KeyValueIterableView{attributes}); } template ::value> * = nullptr> void Add(T value, const U &attributes, const context::Context &context) noexcept { this->Add(value, common::KeyValueIterableView{attributes}, context); } void Add(T value, std::initializer_list> attributes) noexcept { this->Add(value, nostd::span>{ attributes.begin(), attributes.end()}); } void Add(T value, std::initializer_list> attributes, const context::Context &context) noexcept { this->Add(value, nostd::span>{ attributes.begin(), attributes.end()}, context); } }; #if OPENTELEMETRY_ABI_VERSION_NO >= 2 /* A Gauge instrument that records values. */ template class Gauge : public SynchronousInstrument { public: /** * Record a value * * @param value The measurement value. May be positive, negative or zero. */ virtual void Record(T value) noexcept = 0; /** * Record a value * * @param value The measurement value. May be positive, negative or zero. * @param context The explicit context to associate with this measurement. */ virtual void Record(T value, const context::Context &context) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The measurement value. May be positive, negative or zero. * @param attributes A set of attributes to associate with the value. */ virtual void Record(T value, const common::KeyValueIterable &attributes) noexcept = 0; /** * Record a value with a set of attributes. * * @param value The measurement value. May be positive, negative or zero. * @param attributes A set of attributes to associate with the value. * @param context The explicit context to associate with this measurement. */ virtual void Record(T value, const common::KeyValueIterable &attributes, const context::Context &context) noexcept = 0; template ::value> * = nullptr> void Record(T value, const U &attributes) noexcept { this->Record(value, common::KeyValueIterableView{attributes}); } template ::value> * = nullptr> void Record(T value, const U &attributes, const context::Context &context) noexcept { this->Record(value, common::KeyValueIterableView{attributes}, context); } void Record(T value, std::initializer_list> attributes) noexcept { this->Record(value, nostd::span>{ attributes.begin(), attributes.end()}); } void Record( T value, std::initializer_list> attributes, const context::Context &context) noexcept { this->Record(value, nostd::span>{ attributes.begin(), attributes.end()}, context); } }; #endif } // namespace metrics OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/000077500000000000000000000000001474412371400235045ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/000077500000000000000000000000001474412371400247465ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/all.h000066400000000000000000000007111474412371400256660ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/utility.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { template using all = std::is_same, integer_sequence>; } // namespace detail } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/decay.h000066400000000000000000000004741474412371400262110ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template using decay_t = typename std::decay::type; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/dependent_type.h000066400000000000000000000005371474412371400301330ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { template struct dependent_type : T {}; } // namespace detail } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/functional.h000066400000000000000000000033561474412371400272700ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/version.h" #define OPENTELEMETRY_RETURN(...) \ noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ { \ return __VA_ARGS__; \ } OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { struct equal_to { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) == std::forward(rhs)) }; struct not_equal_to { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) != std::forward(rhs)) }; struct less { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) < std::forward(rhs)) }; struct greater { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) > std::forward(rhs)) }; struct less_equal { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) <= std::forward(rhs)) }; struct greater_equal { template inline constexpr auto operator()(Lhs &&lhs, Rhs &&rhs) const OPENTELEMETRY_RETURN(std::forward(lhs) >= std::forward(rhs)) }; } // namespace detail } // namespace nostd OPENTELEMETRY_END_NAMESPACE #undef OPENTELEMETRY_RETURN opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/invoke.h000066400000000000000000000116571474412371400264240ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/nostd/detail/decay.h" #include "opentelemetry/nostd/detail/void.h" #include "opentelemetry/version.h" #define OPENTELEMETRY_RETURN(...) \ noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \ { \ return __VA_ARGS__; \ } OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { template struct is_reference_wrapper : std::false_type {}; template struct is_reference_wrapper> : std::true_type {}; template struct Invoke; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN((std::forward(arg).*pmf)(std::forward(args)...)) }; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN((std::forward(arg).get().*pmf)(std::forward(args)...)) }; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmf, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN(((*std::forward(arg)).*pmf)(std::forward(args)...)) }; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmo, Arg &&arg) OPENTELEMETRY_RETURN(std::forward(arg).*pmo) }; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmo, Arg &&arg) OPENTELEMETRY_RETURN(std::forward(arg).get().*pmo) }; template <> struct Invoke { template inline static constexpr auto invoke(R T::*pmo, Arg &&arg) OPENTELEMETRY_RETURN((*std::forward(arg)).*pmo) }; template inline constexpr auto invoke_impl(R T::*f, Arg &&arg, Args &&...args) OPENTELEMETRY_RETURN( Invoke::value, (std::is_base_of>::value ? 0 : is_reference_wrapper>::value ? 1 : 2)>::invoke(f, std::forward(arg), std::forward(args)...)) #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable : 4100) #endif template inline constexpr auto invoke_impl(F &&f, Args &&...args) OPENTELEMETRY_RETURN(std::forward(f)(std::forward(args)...)) #ifdef _MSC_VER # pragma warning(pop) #endif } // namespace detail /* clang-format off */ template inline constexpr auto invoke(F &&f, Args &&... args) OPENTELEMETRY_RETURN(detail::invoke_impl(std::forward(f), std::forward(args)...)) namespace detail /* clang-format on */ { template struct invoke_result {}; template struct invoke_result(), std::declval()...))>, F, Args...> { using type = decltype(nostd::invoke(std::declval(), std::declval()...)); }; } // namespace detail template using invoke_result = detail::invoke_result; template using invoke_result_t = typename invoke_result::type; namespace detail { template struct is_invocable : std::false_type {}; template struct is_invocable>, F, Args...> : std::true_type {}; template struct is_invocable_r : std::false_type {}; template struct is_invocable_r>, R, F, Args...> : std::is_convertible, R> {}; } // namespace detail template using is_invocable = detail::is_invocable; template using is_invocable_r = detail::is_invocable_r; } // namespace nostd OPENTELEMETRY_END_NAMESPACE #undef OPENTELEMETRY_RETURN opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/trait.h000066400000000000000000000041501474412371400262420ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { enum class Trait { TriviallyAvailable, Available, Unavailable }; template class IsTriviallyAvailable, template class IsAvailable> inline constexpr Trait trait() { return IsTriviallyAvailable::value ? Trait::TriviallyAvailable : IsAvailable::value ? Trait::Available : Trait::Unavailable; } inline constexpr Trait common_trait_impl(Trait result) { return result; } template inline constexpr Trait common_trait_impl(Trait result, Trait t, Traits... ts) { return static_cast(t) > static_cast(result) ? common_trait_impl(t, ts...) : common_trait_impl(result, ts...); } template inline constexpr Trait common_trait(Traits... ts) { return common_trait_impl(Trait::TriviallyAvailable, ts...); } template struct traits { static constexpr Trait copy_constructible_trait = common_trait(trait()...); static constexpr Trait move_constructible_trait = common_trait(trait()...); static constexpr Trait copy_assignable_trait = common_trait(copy_constructible_trait, trait()...); static constexpr Trait move_assignable_trait = common_trait(move_constructible_trait, trait()...); static constexpr Trait destructible_trait = common_trait(trait()...); }; } // namespace detail } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/type_pack_element.h000066400000000000000000000022701474412371400306100ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include #include "opentelemetry/nostd/utility.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { template using size_constant = std::integral_constant; template struct indexed_type : size_constant { using type = T; }; template struct type_pack_element_impl { private: template struct set; template struct set> : indexed_type... {}; template inline static std::enable_if impl(indexed_type); inline static std::enable_if impl(...); public: using type = decltype(impl(set>{})); }; template using type_pack_element = typename type_pack_element_impl::type; template using type_pack_element_t = typename type_pack_element::type; } // namespace detail } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/valueless.h000066400000000000000000000003721474412371400271240ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { struct valueless_t {}; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/variant_alternative.h000066400000000000000000000022171474412371400311630ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/detail/type_pack_element.h" #include "opentelemetry/nostd/detail/variant_fwd.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template struct variant_alternative; template using variant_alternative_t = typename variant_alternative::type; template struct variant_alternative : std::add_const> {}; template struct variant_alternative : std::add_volatile> {}; template struct variant_alternative : std::add_cv> {}; template struct variant_alternative> { static_assert(I < sizeof...(Ts), "index out of bounds in `std::variant_alternative<>`"); using type = detail::type_pack_element_t; }; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/variant_fwd.h000066400000000000000000000004141474412371400274220ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template class variant; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/variant_size.h000066400000000000000000000012671474412371400276230ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include "opentelemetry/nostd/detail/variant_fwd.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template struct variant_size; template struct variant_size : variant_size {}; template struct variant_size : variant_size {}; template struct variant_size : variant_size {}; template struct variant_size> : std::integral_constant {}; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/detail/void.h000066400000000000000000000010041474412371400260530ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { namespace detail { template struct voider { using type = void; }; } // namespace detail /** * Back port of std::void_t * * Note: voider workaround is required for gcc-4.8 to make SFINAE work */ template using void_t = typename detail::voider::type; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/function_ref.h000066400000000000000000000051031474412371400263350ustar00rootroot00000000000000// Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 #pragma once #include #include // IWYU pragma: keep #include #include #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { template class function_ref; // IWYU pragma: keep /** * Non-owning function reference that can be used as a more performant * replacement for std::function when ownership sematics aren't needed. * * See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0792r0.html * * Based off of https://stackoverflow.com/a/39087660/4447365 */ template class function_ref { void *callable_ = nullptr; R (*invoker_)(void *, Args...) = nullptr; template using FunctionPointer = decltype(std::addressof(std::declval())); template void BindTo(F &f) noexcept { callable_ = static_cast(std::addressof(f)); invoker_ = [](void *callable, Args... args) -> R { return (*static_cast>(callable))(std::forward(args)...); }; } template void BindTo(R_in (*f)(Args_in...)) noexcept { using F = decltype(f); if (f == nullptr) { return BindTo(nullptr); } callable_ = reinterpret_cast(f); invoker_ = [](void *callable, Args... args) -> R { return (F(callable))(std::forward(args)...); }; } void BindTo(std::nullptr_t) noexcept { callable_ = nullptr; invoker_ = nullptr; } public: template < class F, typename std::enable_if::type>::value, int>::type = 0, typename std::enable_if< #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402)) // std::result_of deprecated in C++17, removed in C++20 std::is_convertible::type, R>::value, #else // std::result_of since C++11 std::is_convertible::type, R>::value, #endif int>::type = 0> function_ref(F &&f) { BindTo(f); // not forward } function_ref(std::nullptr_t) {} function_ref(const function_ref &) noexcept = default; function_ref(function_ref &&) noexcept = default; R operator()(Args... args) const { return invoker_(callable_, std::forward(args)...); } explicit operator bool() const { return invoker_; } }; } // namespace nostd OPENTELEMETRY_END_NAMESPACE opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/000077500000000000000000000000001474412371400253205ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/000077500000000000000000000000001474412371400262415ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/.clang-format000066400000000000000000000001401474412371400306070ustar00rootroot00000000000000# Disable formatting for Google Abseil library snapshot DisableFormat: true SortIncludes: false opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/README.md000066400000000000000000000002321474412371400275150ustar00rootroot00000000000000# Notes on Abseil Variant implementation This is a snapshot of Abseil Variant `absl::OTABSL_OPTION_NAMESPACE_NAME::variant` from Abseil `v2020-03-03#8`. opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/000077500000000000000000000000001474412371400271535ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/attributes.h000066400000000000000000000604641474412371400315240ustar00rootroot00000000000000// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // This header file defines macros for declaring attributes for functions, // types, and variables. // // These macros are used within Abseil and allow the compiler to optimize, where // applicable, certain function calls. // // This file is used for both C and C++! // // Most macros here are exposing GCC or Clang features, and are stubbed out for // other compilers. // // GCC attributes documentation: // https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html // https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Variable-Attributes.html // https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Type-Attributes.html // // Most attributes in this file are already supported by GCC 4.7. However, some // of them are not supported in older version of Clang. Thus, we check // `__has_attribute()` first. If the check fails, we check if we are on GCC and // assume the attribute exists on GCC (which is verified on GCC 4.7). // // ----------------------------------------------------------------------------- // Sanitizer Attributes // ----------------------------------------------------------------------------- // // Sanitizer-related attributes are not "defined" in this file (and indeed // are not defined as such in any file). To utilize the following // sanitizer-related attributes within your builds, define the following macros // within your build using a `-D` flag, along with the given value for // `-fsanitize`: // // * `ADDRESS_SANITIZER` + `-fsanitize=address` (Clang, GCC 4.8) // * `MEMORY_SANITIZER` + `-fsanitize=memory` (Clang-only) // * `THREAD_SANITIZER + `-fsanitize=thread` (Clang, GCC 4.8+) // * `UNDEFINED_BEHAVIOR_SANITIZER` + `-fsanitize=undefined` (Clang, GCC 4.9+) // * `CONTROL_FLOW_INTEGRITY` + -fsanitize=cfi (Clang-only) // // Example: // // // Enable branches in the Abseil code that are tagged for ASan: // $ bazel build --copt=-DADDRESS_SANITIZER --copt=-fsanitize=address // --linkopt=-fsanitize=address *target* // // Since these macro names are only supported by GCC and Clang, we only check // for `__GNUC__` (GCC or Clang) and the above macros. #ifndef OTABSL_BASE_ATTRIBUTES_H_ #define OTABSL_BASE_ATTRIBUTES_H_ // OTABSL_HAVE_ATTRIBUTE // // A function-like feature checking macro that is a wrapper around // `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a // nonzero constant integer if the attribute is supported or 0 if not. // // It evaluates to zero if `__has_attribute` is not defined by the compiler. // // GCC: https://gcc.gnu.org/gcc-5/changes.html // Clang: https://clang.llvm.org/docs/LanguageExtensions.html #ifdef __has_attribute #define OTABSL_HAVE_ATTRIBUTE(x) __has_attribute(x) #else #define OTABSL_HAVE_ATTRIBUTE(x) 0 #endif // OTABSL_HAVE_CPP_ATTRIBUTE // // A function-like feature checking macro that accepts C++11 style attributes. // It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6 // (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't // find `__has_cpp_attribute`, will evaluate to 0. #if defined(__cplusplus) && defined(__has_cpp_attribute) // NOTE: requiring __cplusplus above should not be necessary, but // works around https://bugs.llvm.org/show_bug.cgi?id=23435. #define OTABSL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #else #define OTABSL_HAVE_CPP_ATTRIBUTE(x) 0 #endif // ----------------------------------------------------------------------------- // Function Attributes // ----------------------------------------------------------------------------- // // GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html // Clang: https://clang.llvm.org/docs/AttributeReference.html // OTABSL_PRINTF_ATTRIBUTE // OTABSL_SCANF_ATTRIBUTE // // Tells the compiler to perform `printf` format string checking if the // compiler supports it; see the 'format' attribute in // . // // Note: As the GCC manual states, "[s]ince non-static C++ methods // have an implicit 'this' argument, the arguments of such methods // should be counted from two, not one." #if OTABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \ __attribute__((__format__(__printf__, string_index, first_to_check))) #define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \ __attribute__((__format__(__scanf__, string_index, first_to_check))) #else #define OTABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) #define OTABSL_SCANF_ATTRIBUTE(string_index, first_to_check) #endif // OTABSL_ATTRIBUTE_ALWAYS_INLINE // OTABSL_ATTRIBUTE_NOINLINE // // Forces functions to either inline or not inline. Introduced in gcc 3.1. #if OTABSL_HAVE_ATTRIBUTE(always_inline) || \ (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) #define OTABSL_HAVE_ATTRIBUTE_ALWAYS_INLINE 1 #else #define OTABSL_ATTRIBUTE_ALWAYS_INLINE #endif #if OTABSL_HAVE_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_NOINLINE __attribute__((noinline)) #define OTABSL_HAVE_ATTRIBUTE_NOINLINE 1 #else #define OTABSL_ATTRIBUTE_NOINLINE #endif // OTABSL_ATTRIBUTE_NO_TAIL_CALL // // Prevents the compiler from optimizing away stack frames for functions which // end in a call to another function. #if OTABSL_HAVE_ATTRIBUTE(disable_tail_calls) #define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 #define OTABSL_ATTRIBUTE_NO_TAIL_CALL __attribute__((disable_tail_calls)) #elif defined(__GNUC__) && !defined(__clang__) #define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1 #define OTABSL_ATTRIBUTE_NO_TAIL_CALL \ __attribute__((optimize("no-optimize-sibling-calls"))) #else #define OTABSL_ATTRIBUTE_NO_TAIL_CALL #define OTABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 0 #endif // OTABSL_ATTRIBUTE_WEAK // // Tags a function as weak for the purposes of compilation and linking. // Weak attributes currently do not work properly in LLVM's Windows backend, // so disable them there. See https://bugs.llvm.org/show_bug.cgi?id=37598 // for further information. // The MinGW compiler doesn't complain about the weak attribute until the link // step, presumably because Windows doesn't use ELF binaries. #if (OTABSL_HAVE_ATTRIBUTE(weak) || \ (defined(__GNUC__) && !defined(__clang__))) && \ !(defined(__llvm__) && defined(_WIN32)) && !defined(__MINGW32__) #undef OTABSL_ATTRIBUTE_WEAK #define OTABSL_ATTRIBUTE_WEAK __attribute__((weak)) #define OTABSL_HAVE_ATTRIBUTE_WEAK 1 #else #define OTABSL_ATTRIBUTE_WEAK #define OTABSL_HAVE_ATTRIBUTE_WEAK 0 #endif // OTABSL_ATTRIBUTE_NONNULL // // Tells the compiler either (a) that a particular function parameter // should be a non-null pointer, or (b) that all pointer arguments should // be non-null. // // Note: As the GCC manual states, "[s]ince non-static C++ methods // have an implicit 'this' argument, the arguments of such methods // should be counted from two, not one." // // Args are indexed starting at 1. // // For non-static class member functions, the implicit `this` argument // is arg 1, and the first explicit argument is arg 2. For static class member // functions, there is no implicit `this`, and the first explicit argument is // arg 1. // // Example: // // /* arg_a cannot be null, but arg_b can */ // void Function(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(1); // // class C { // /* arg_a cannot be null, but arg_b can */ // void Method(void* arg_a, void* arg_b) OTABSL_ATTRIBUTE_NONNULL(2); // // /* arg_a cannot be null, but arg_b can */ // static void StaticMethod(void* arg_a, void* arg_b) // OTABSL_ATTRIBUTE_NONNULL(1); // }; // // If no arguments are provided, then all pointer arguments should be non-null. // // /* No pointer arguments may be null. */ // void Function(void* arg_a, void* arg_b, int arg_c) OTABSL_ATTRIBUTE_NONNULL(); // // NOTE: The GCC nonnull attribute actually accepts a list of arguments, but // OTABSL_ATTRIBUTE_NONNULL does not. #if OTABSL_HAVE_ATTRIBUTE(nonnull) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_NONNULL(arg_index) __attribute__((nonnull(arg_index))) #else #define OTABSL_ATTRIBUTE_NONNULL(...) #endif // OTABSL_ATTRIBUTE_NORETURN // // Tells the compiler that a given function never returns. #if OTABSL_HAVE_ATTRIBUTE(noreturn) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) #define OTABSL_ATTRIBUTE_NORETURN __declspec(noreturn) #else #define OTABSL_ATTRIBUTE_NORETURN #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS // // Tells the AddressSanitizer (or other memory testing tools) to ignore a given // function. Useful for cases when a function reads random locations on stack, // calls _exit from a cloned subprocess, deliberately accesses buffer // out of bounds or does other scary things with memory. // NOTE: GCC supports AddressSanitizer(asan) since 4.8. // https://gcc.gnu.org/gcc-4.8/changes.html #if defined(__GNUC__) #define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY // // Tells the MemorySanitizer to relax the handling of a given function. All // "Use of uninitialized value" warnings from such functions will be suppressed, // and all values loaded from memory will be considered fully initialized. // This attribute is similar to the ADDRESS_SANITIZER attribute above, but deals // with initialized-ness rather than addressability issues. // NOTE: MemorySanitizer(msan) is supported by Clang but not GCC. #if defined(__clang__) #define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory)) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_MEMORY #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD // // Tells the ThreadSanitizer to not instrument a given function. // NOTE: GCC supports ThreadSanitizer(tsan) since 4.8. // https://gcc.gnu.org/gcc-4.8/changes.html #if defined(__GNUC__) #define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread)) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_THREAD #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED // // Tells the UndefinedSanitizer to ignore a given function. Useful for cases // where certain behavior (eg. division by zero) is being used intentionally. // NOTE: GCC supports UndefinedBehaviorSanitizer(ubsan) since 4.9. // https://gcc.gnu.org/gcc-4.9/changes.html #if defined(__GNUC__) && \ (defined(UNDEFINED_BEHAVIOR_SANITIZER) || defined(ADDRESS_SANITIZER)) #define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED \ __attribute__((no_sanitize("undefined"))) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_CFI // // Tells the ControlFlowIntegrity sanitizer to not instrument a given function. // See https://clang.llvm.org/docs/ControlFlowIntegrity.html for details. #if defined(__GNUC__) && defined(CONTROL_FLOW_INTEGRITY) #define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI __attribute__((no_sanitize("cfi"))) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_CFI #endif // OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK // // Tells the SafeStack to not instrument a given function. // See https://clang.llvm.org/docs/SafeStack.html for details. #if defined(__GNUC__) && defined(SAFESTACK_SANITIZER) #define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK \ __attribute__((no_sanitize("safe-stack"))) #else #define OTABSL_ATTRIBUTE_NO_SANITIZE_SAFESTACK #endif // OTABSL_ATTRIBUTE_RETURNS_NONNULL // // Tells the compiler that a particular function never returns a null pointer. #if OTABSL_HAVE_ATTRIBUTE(returns_nonnull) || \ (defined(__GNUC__) && \ (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && \ !defined(__clang__)) #define OTABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #else #define OTABSL_ATTRIBUTE_RETURNS_NONNULL #endif // OTABSL_HAVE_ATTRIBUTE_SECTION // // Indicates whether labeled sections are supported. Weak symbol support is // a prerequisite. Labeled sections are not supported on Darwin/iOS. #ifdef OTABSL_HAVE_ATTRIBUTE_SECTION #error OTABSL_HAVE_ATTRIBUTE_SECTION cannot be directly set #elif (OTABSL_HAVE_ATTRIBUTE(section) || \ (defined(__GNUC__) && !defined(__clang__))) && \ !defined(__APPLE__) && OTABSL_HAVE_ATTRIBUTE_WEAK #define OTABSL_HAVE_ATTRIBUTE_SECTION 1 // OTABSL_ATTRIBUTE_SECTION // // Tells the compiler/linker to put a given function into a section and define // `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. // This functionality is supported by GNU linker. Any function annotated with // `OTABSL_ATTRIBUTE_SECTION` must not be inlined, or it will be placed into // whatever section its caller is placed into. // #ifndef OTABSL_ATTRIBUTE_SECTION #define OTABSL_ATTRIBUTE_SECTION(name) \ __attribute__((section(#name))) __attribute__((noinline)) #endif // OTABSL_ATTRIBUTE_SECTION_VARIABLE // // Tells the compiler/linker to put a given variable into a section and define // `__start_ ## name` and `__stop_ ## name` symbols to bracket the section. // This functionality is supported by GNU linker. #ifndef OTABSL_ATTRIBUTE_SECTION_VARIABLE #define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name))) #endif // OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS // // A weak section declaration to be used as a global declaration // for OTABSL_ATTRIBUTE_SECTION_START|STOP(name) to compile and link // even without functions with OTABSL_ATTRIBUTE_SECTION(name). // OTABSL_DEFINE_ATTRIBUTE_SECTION should be in the exactly one file; it's // a no-op on ELF but not on Mach-O. // #ifndef OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS #define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) \ extern char __start_##name[] OTABSL_ATTRIBUTE_WEAK; \ extern char __stop_##name[] OTABSL_ATTRIBUTE_WEAK #endif #ifndef OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS #define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) #define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) #endif // OTABSL_ATTRIBUTE_SECTION_START // // Returns `void*` pointers to start/end of a section of code with // functions having OTABSL_ATTRIBUTE_SECTION(name). // Returns 0 if no such functions exist. // One must OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) for this to compile and // link. // #define OTABSL_ATTRIBUTE_SECTION_START(name) \ (reinterpret_cast(__start_##name)) #define OTABSL_ATTRIBUTE_SECTION_STOP(name) \ (reinterpret_cast(__stop_##name)) #else // !OTABSL_HAVE_ATTRIBUTE_SECTION #define OTABSL_HAVE_ATTRIBUTE_SECTION 0 // provide dummy definitions #define OTABSL_ATTRIBUTE_SECTION(name) #define OTABSL_ATTRIBUTE_SECTION_VARIABLE(name) #define OTABSL_INIT_ATTRIBUTE_SECTION_VARS(name) #define OTABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name) #define OTABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) #define OTABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast(0)) #define OTABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast(0)) #endif // OTABSL_ATTRIBUTE_SECTION // OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC // // Support for aligning the stack on 32-bit x86. #if OTABSL_HAVE_ATTRIBUTE(force_align_arg_pointer) || \ (defined(__GNUC__) && !defined(__clang__)) #if defined(__i386__) #define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC \ __attribute__((force_align_arg_pointer)) #define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) #elif defined(__x86_64__) #define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (1) #define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC #else // !__i386__ && !__x86_64 #define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) #define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC #endif // __i386__ #else #define OTABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC #define OTABSL_REQUIRE_STACK_ALIGN_TRAMPOLINE (0) #endif // OTABSL_MUST_USE_RESULT // // Tells the compiler to warn about unused results. // // When annotating a function, it must appear as the first part of the // declaration or definition. The compiler will warn if the return value from // such a function is unused: // // OTABSL_MUST_USE_RESULT Sprocket* AllocateSprocket(); // AllocateSprocket(); // Triggers a warning. // // When annotating a class, it is equivalent to annotating every function which // returns an instance. // // class OTABSL_MUST_USE_RESULT Sprocket {}; // Sprocket(); // Triggers a warning. // // Sprocket MakeSprocket(); // MakeSprocket(); // Triggers a warning. // // Note that references and pointers are not instances: // // Sprocket* SprocketPointer(); // SprocketPointer(); // Does *not* trigger a warning. // // OTABSL_MUST_USE_RESULT allows using cast-to-void to suppress the unused result // warning. For that, warn_unused_result is used only for clang but not for gcc. // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 // // Note: past advice was to place the macro after the argument list. #if OTABSL_HAVE_ATTRIBUTE(nodiscard) #define OTABSL_MUST_USE_RESULT [[nodiscard]] #elif defined(__clang__) && OTABSL_HAVE_ATTRIBUTE(warn_unused_result) #define OTABSL_MUST_USE_RESULT __attribute__((warn_unused_result)) #else #define OTABSL_MUST_USE_RESULT #endif // OTABSL_ATTRIBUTE_HOT, OTABSL_ATTRIBUTE_COLD // // Tells GCC that a function is hot or cold. GCC can use this information to // improve static analysis, i.e. a conditional branch to a cold function // is likely to be not-taken. // This annotation is used for function declarations. // // Example: // // int foo() OTABSL_ATTRIBUTE_HOT; #if OTABSL_HAVE_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_HOT __attribute__((hot)) #else #define OTABSL_ATTRIBUTE_HOT #endif #if OTABSL_HAVE_ATTRIBUTE(cold) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_COLD __attribute__((cold)) #else #define OTABSL_ATTRIBUTE_COLD #endif // OTABSL_XRAY_ALWAYS_INSTRUMENT, OTABSL_XRAY_NEVER_INSTRUMENT, OTABSL_XRAY_LOG_ARGS // // We define the OTABSL_XRAY_ALWAYS_INSTRUMENT and OTABSL_XRAY_NEVER_INSTRUMENT // macro used as an attribute to mark functions that must always or never be // instrumented by XRay. Currently, this is only supported in Clang/LLVM. // // For reference on the LLVM XRay instrumentation, see // http://llvm.org/docs/XRay.html. // // A function with the XRAY_ALWAYS_INSTRUMENT macro attribute in its declaration // will always get the XRay instrumentation sleds. These sleds may introduce // some binary size and runtime overhead and must be used sparingly. // // These attributes only take effect when the following conditions are met: // // * The file/target is built in at least C++11 mode, with a Clang compiler // that supports XRay attributes. // * The file/target is built with the -fxray-instrument flag set for the // Clang/LLVM compiler. // * The function is defined in the translation unit (the compiler honors the // attribute in either the definition or the declaration, and must match). // // There are cases when, even when building with XRay instrumentation, users // might want to control specifically which functions are instrumented for a // particular build using special-case lists provided to the compiler. These // special case lists are provided to Clang via the // -fxray-always-instrument=... and -fxray-never-instrument=... flags. The // attributes in source take precedence over these special-case lists. // // To disable the XRay attributes at build-time, users may define // OTABSL_NO_XRAY_ATTRIBUTES. Do NOT define OTABSL_NO_XRAY_ATTRIBUTES on specific // packages/targets, as this may lead to conflicting definitions of functions at // link-time. // #if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_always_instrument) && \ !defined(OTABSL_NO_XRAY_ATTRIBUTES) #define OTABSL_XRAY_ALWAYS_INSTRUMENT [[clang::xray_always_instrument]] #define OTABSL_XRAY_NEVER_INSTRUMENT [[clang::xray_never_instrument]] #if OTABSL_HAVE_CPP_ATTRIBUTE(clang::xray_log_args) #define OTABSL_XRAY_LOG_ARGS(N) \ [[clang::xray_always_instrument, clang::xray_log_args(N)]] #else #define OTABSL_XRAY_LOG_ARGS(N) [[clang::xray_always_instrument]] #endif #else #define OTABSL_XRAY_ALWAYS_INSTRUMENT #define OTABSL_XRAY_NEVER_INSTRUMENT #define OTABSL_XRAY_LOG_ARGS(N) #endif // OTABSL_ATTRIBUTE_REINITIALIZES // // Indicates that a member function reinitializes the entire object to a known // state, independent of the previous state of the object. // // The clang-tidy check bugprone-use-after-move allows member functions marked // with this attribute to be called on objects that have been moved from; // without the attribute, this would result in a use-after-move warning. #if OTABSL_HAVE_CPP_ATTRIBUTE(clang::reinitializes) #define OTABSL_ATTRIBUTE_REINITIALIZES [[clang::reinitializes]] #else #define OTABSL_ATTRIBUTE_REINITIALIZES #endif // ----------------------------------------------------------------------------- // Variable Attributes // ----------------------------------------------------------------------------- // OTABSL_ATTRIBUTE_UNUSED // // Prevents the compiler from complaining about variables that appear unused. #if OTABSL_HAVE_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__)) #undef OTABSL_ATTRIBUTE_UNUSED #define OTABSL_ATTRIBUTE_UNUSED __attribute__((__unused__)) #else #define OTABSL_ATTRIBUTE_UNUSED #endif // OTABSL_ATTRIBUTE_INITIAL_EXEC // // Tells the compiler to use "initial-exec" mode for a thread-local variable. // See http://people.redhat.com/drepper/tls.pdf for the gory details. #if OTABSL_HAVE_ATTRIBUTE(tls_model) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_INITIAL_EXEC __attribute__((tls_model("initial-exec"))) #else #define OTABSL_ATTRIBUTE_INITIAL_EXEC #endif // OTABSL_ATTRIBUTE_PACKED // // Instructs the compiler not to use natural alignment for a tagged data // structure, but instead to reduce its alignment to 1. This attribute can // either be applied to members of a structure or to a structure in its // entirety. Applying this attribute (judiciously) to a structure in its // entirety to optimize the memory footprint of very commonly-used structs is // fine. Do not apply this attribute to a structure in its entirety if the // purpose is to control the offsets of the members in the structure. Instead, // apply this attribute only to structure members that need it. // // When applying OTABSL_ATTRIBUTE_PACKED only to specific structure members the // natural alignment of structure members not annotated is preserved. Aligned // member accesses are faster than non-aligned member accesses even if the // targeted microprocessor supports non-aligned accesses. #if OTABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_PACKED __attribute__((__packed__)) #else #define OTABSL_ATTRIBUTE_PACKED #endif // OTABSL_ATTRIBUTE_FUNC_ALIGN // // Tells the compiler to align the function start at least to certain // alignment boundary #if OTABSL_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__((aligned(bytes))) #else #define OTABSL_ATTRIBUTE_FUNC_ALIGN(bytes) #endif // OTABSL_CONST_INIT // // A variable declaration annotated with the `OTABSL_CONST_INIT` attribute will // not compile (on supported platforms) unless the variable has a constant // initializer. This is useful for variables with static and thread storage // duration, because it guarantees that they will not suffer from the so-called // "static init order fiasco". Prefer to put this attribute on the most visible // declaration of the variable, if there's more than one, because code that // accesses the variable can then use the attribute for optimization. // // Example: // // class MyClass { // public: // OTABSL_CONST_INIT static MyType my_var; // }; // // MyType MyClass::my_var = MakeMyType(...); // // Note that this attribute is redundant if the variable is declared constexpr. #if OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) #define OTABSL_CONST_INIT [[clang::require_constant_initialization]] #else #define OTABSL_CONST_INIT #endif // OTABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization) #endif // OTABSL_BASE_ATTRIBUTES_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/config.h000066400000000000000000000624721474412371400306040ustar00rootroot00000000000000// // Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: config.h // ----------------------------------------------------------------------------- // // This header file defines a set of macros for checking the presence of // important compiler and platform features. Such macros can be used to // produce portable code by parameterizing compilation based on the presence or // lack of a given feature. // // We define a "feature" as some interface we wish to program to: for example, // a library function or system call. A value of `1` indicates support for // that feature; any other value indicates the feature support is undefined. // // Example: // // Suppose a programmer wants to write a program that uses the 'mmap()' system // call. The Abseil macro for that feature (`OTABSL_HAVE_MMAP`) allows you to // selectively include the `mmap.h` header and bracket code using that feature // in the macro: // // #include "absl/base/config.h" // // #ifdef OTABSL_HAVE_MMAP // #include "sys/mman.h" // #endif //OTABSL_HAVE_MMAP // // ... // #ifdef OTABSL_HAVE_MMAP // void *ptr = mmap(...); // ... // #endif // OTABSL_HAVE_MMAP #ifndef OTABSL_BASE_CONFIG_H_ #define OTABSL_BASE_CONFIG_H_ // Included for the __GLIBC__ macro (or similar macros on other systems). #include #ifdef __cplusplus // Included for __GLIBCXX__, _LIBCPP_VERSION #include #endif // __cplusplus #if defined(__APPLE__) // Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED, // __IPHONE_8_0. #include #include #endif #include "options.h" #include "policy_checks.h" // Helper macro to convert a CPP variable to a string literal. #define OTABSL_INTERNAL_DO_TOKEN_STR(x) #x #define OTABSL_INTERNAL_TOKEN_STR(x) OTABSL_INTERNAL_DO_TOKEN_STR(x) // ----------------------------------------------------------------------------- // Abseil namespace annotations // ----------------------------------------------------------------------------- // OTABSL_NAMESPACE_BEGIN/OTABSL_NAMESPACE_END // // An annotation placed at the beginning/end of each `namespace absl` scope. // This is used to inject an inline namespace. // // The proper way to write Abseil code in the `absl` namespace is: // // namespace absl { // OTABSL_NAMESPACE_BEGIN // // void Foo(); // absl::OTABSL_OPTION_NAMESPACE_NAME::Foo(). // // OTABSL_NAMESPACE_END // } // namespace absl // // Users of Abseil should not use these macros, because users of Abseil should // not write `namespace absl {` in their own code for any reason. (Abseil does // not support forward declarations of its own types, nor does it support // user-provided specialization of Abseil templates. Code that violates these // rules may be broken without warning.) #if !defined(OTABSL_OPTION_NAMESPACE_NAME) #error options.h is misconfigured. #endif // Check that OTABSL_OPTION_NAMESPACE_NAME is neither "head" nor "" #if defined(__cplusplus) #define OTABSL_INTERNAL_INLINE_NAMESPACE_STR \ OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != '\0', "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "not be empty."); static_assert(OTABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[1] != 'e' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[2] != 'a' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[3] != 'd' || OTABSL_INTERNAL_INLINE_NAMESPACE_STR[4] != '\0', "options.h misconfigured: OTABSL_OPTION_NAMESPACE_NAME must " "be changed to a new, unique identifier name."); #endif #define OTABSL_NAMESPACE_BEGIN namespace OTABSL_OPTION_NAMESPACE_NAME { #define OTABSL_NAMESPACE_END } // ----------------------------------------------------------------------------- // Compiler Feature Checks // ----------------------------------------------------------------------------- // OTABSL_HAVE_BUILTIN() // // Checks whether the compiler supports a Clang Feature Checking Macro, and if // so, checks whether it supports the provided builtin function "x" where x // is one of the functions noted in // https://clang.llvm.org/docs/LanguageExtensions.html // // Note: Use this macro to avoid an extra level of #ifdef __has_builtin check. // http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html #ifdef __has_builtin #define OTABSL_HAVE_BUILTIN(x) __has_builtin(x) #else #define OTABSL_HAVE_BUILTIN(x) 0 #endif #if defined(__is_identifier) #define OTABSL_INTERNAL_HAS_KEYWORD(x) !(__is_identifier(x)) #else #define OTABSL_INTERNAL_HAS_KEYWORD(x) 0 #endif // OTABSL_HAVE_TLS is defined to 1 when __thread should be supported. // We assume __thread is supported on Linux when compiled with Clang or compiled // against libstdc++ with _GLIBCXX_HAVE_TLS defined. #ifdef OTABSL_HAVE_TLS #error OTABSL_HAVE_TLS cannot be directly set #elif defined(__linux__) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS)) #define OTABSL_HAVE_TLS 1 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE // // Checks whether `std::is_trivially_destructible` is supported. // // Notes: All supported compilers using libc++ support this feature, as does // gcc >= 4.8.1 using libstdc++, and Visual Studio. #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE #error OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set #elif defined(_LIBCPP_VERSION) || \ (defined(__clang__) && __clang_major__ >= 15) || \ (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && \ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ defined(_MSC_VER) #define OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE // // Checks whether `std::is_trivially_default_constructible` and // `std::is_trivially_copy_constructible` are supported. // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE // // Checks whether `std::is_trivially_copy_assignable` is supported. // Notes: Clang with libc++ supports these features, as does gcc >= 5.1 with // either libc++ or libstdc++, and Visual Studio (but not NVCC). #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) #error OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set #elif defined(OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) #error OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set #elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ (defined(__clang__) && __clang_major__ >= 15) || \ (!defined(__clang__) && defined(__GNUC__) && \ (__GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ >= 4)) && \ (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ (defined(_MSC_VER) && !defined(__NVCC__)) #define OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 #define OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE // // Checks whether `std::is_trivially_copyable` is supported. // // Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested. #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE) #error OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set #elif defined(__clang__) && (__clang_major__ >= 15) #define OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1 #endif // OTABSL_HAVE_SOURCE_LOCATION_CURRENT // // Indicates whether `absl::OTABSL_OPTION_NAMESPACE_NAME::SourceLocation::current()` will return useful // information in some contexts. #ifndef OTABSL_HAVE_SOURCE_LOCATION_CURRENT #if OTABSL_INTERNAL_HAS_KEYWORD(__builtin_LINE) && \ OTABSL_INTERNAL_HAS_KEYWORD(__builtin_FILE) #define OTABSL_HAVE_SOURCE_LOCATION_CURRENT 1 #endif #endif // OTABSL_HAVE_THREAD_LOCAL // // Checks whether C++11's `thread_local` storage duration specifier is // supported. #ifdef OTABSL_HAVE_THREAD_LOCAL #error OTABSL_HAVE_THREAD_LOCAL cannot be directly set #elif defined(__APPLE__) // Notes: // * Xcode's clang did not support `thread_local` until version 8, and // even then not for all iOS < 9.0. // * Xcode 9.3 started disallowing `thread_local` for 32-bit iOS simulator // targeting iOS 9.x. // * Xcode 10 moves the deployment target check for iOS < 9.0 to link time // making __has_feature unreliable there. // // Otherwise, `__has_feature` is only supported by Clang so it has be inside // `defined(__APPLE__)` check. #if __has_feature(cxx_thread_local) && \ !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) #define OTABSL_HAVE_THREAD_LOCAL 1 #endif #else // !defined(__APPLE__) #define OTABSL_HAVE_THREAD_LOCAL 1 #endif // There are platforms for which TLS should not be used even though the compiler // makes it seem like it's supported (Android NDK < r12b for example). // This is primarily because of linker problems and toolchain misconfiguration: // Abseil does not intend to support this indefinitely. Currently, the newest // toolchain that we intend to support that requires this behavior is the // r11 NDK - allowing for a 5 year support window on that means this option // is likely to be removed around June of 2021. // TLS isn't supported until NDK r12b per // https://developer.android.com/ndk/downloads/revision_history.html // Since NDK r16, `__NDK_MAJOR__` and `__NDK_MINOR__` are defined in // . For NDK < r16, users should define these macros, // e.g. `-D__NDK_MAJOR__=11 -D__NKD_MINOR__=0` for NDK r11. #if defined(__ANDROID__) && defined(__clang__) #if __has_include() #include #endif // __has_include() #if defined(__ANDROID__) && defined(__clang__) && defined(__NDK_MAJOR__) && \ defined(__NDK_MINOR__) && \ ((__NDK_MAJOR__ < 12) || ((__NDK_MAJOR__ == 12) && (__NDK_MINOR__ < 1))) #undef OTABSL_HAVE_TLS #undef OTABSL_HAVE_THREAD_LOCAL #endif #endif // defined(__ANDROID__) && defined(__clang__) // Emscripten doesn't yet support `thread_local` or `__thread`. // https://github.com/emscripten-core/emscripten/issues/3502 #if defined(__EMSCRIPTEN__) #undef OTABSL_HAVE_TLS #undef OTABSL_HAVE_THREAD_LOCAL #endif // defined(__EMSCRIPTEN__) // OTABSL_HAVE_INTRINSIC_INT128 // // Checks whether the __int128 compiler extension for a 128-bit integral type is // supported. // // Note: __SIZEOF_INT128__ is defined by Clang and GCC when __int128 is // supported, but we avoid using it in certain cases: // * On Clang: // * Building using Clang for Windows, where the Clang runtime library has // 128-bit support only on LP64 architectures, but Windows is LLP64. // * On Nvidia's nvcc: // * nvcc also defines __GNUC__ and __SIZEOF_INT128__, but not all versions // actually support __int128. #ifdef OTABSL_HAVE_INTRINSIC_INT128 #error OTABSL_HAVE_INTRINSIC_INT128 cannot be directly set #elif defined(__SIZEOF_INT128__) #if (defined(__clang__) && !defined(_WIN32)) || \ (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__)) #define OTABSL_HAVE_INTRINSIC_INT128 1 #elif defined(__CUDACC__) // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a // string explaining that it has been removed starting with CUDA 9. We use // nested #ifs because there is no short-circuiting in the preprocessor. // NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined. #if __CUDACC_VER__ >= 70000 #define OTABSL_HAVE_INTRINSIC_INT128 1 #endif // __CUDACC_VER__ >= 70000 #endif // defined(__CUDACC__) #endif // OTABSL_HAVE_INTRINSIC_INT128 // OTABSL_HAVE_EXCEPTIONS // // Checks whether the compiler both supports and enables exceptions. Many // compilers support a "no exceptions" mode that disables exceptions. // // Generally, when OTABSL_HAVE_EXCEPTIONS is not defined: // // * Code using `throw` and `try` may not compile. // * The `noexcept` specifier will still compile and behave as normal. // * The `noexcept` operator may still return `false`. // // For further details, consult the compiler's documentation. #ifdef OTABSL_HAVE_EXCEPTIONS #error OTABSL_HAVE_EXCEPTIONS cannot be directly set. #elif defined(__clang__) #if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) // Clang >= 3.6 #if __has_feature(cxx_exceptions) #define OTABSL_HAVE_EXCEPTIONS 1 #endif // __has_feature(cxx_exceptions) #else // Clang < 3.6 // http://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro #if defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) #define OTABSL_HAVE_EXCEPTIONS 1 #endif // defined(__EXCEPTIONS) && __has_feature(cxx_exceptions) #endif // __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 6) // Handle remaining special cases and default to exceptions being supported. #elif !(defined(__GNUC__) && (__GNUC__ < 5) && !defined(__EXCEPTIONS)) && \ !(defined(__GNUC__) && (__GNUC__ >= 5) && !defined(__cpp_exceptions)) && \ !(defined(_MSC_VER) && !defined(_CPPUNWIND)) #define OTABSL_HAVE_EXCEPTIONS 1 #endif // ----------------------------------------------------------------------------- // Platform Feature Checks // ----------------------------------------------------------------------------- // Currently supported operating systems and associated preprocessor // symbols: // // Linux and Linux-derived __linux__ // Android __ANDROID__ (implies __linux__) // Linux (non-Android) __linux__ && !__ANDROID__ // Darwin (macOS and iOS) __APPLE__ // Akaros (http://akaros.org) __ros__ // Windows _WIN32 // NaCL __native_client__ // AsmJS __asmjs__ // WebAssembly __wasm__ // Fuchsia __Fuchsia__ // // Note that since Android defines both __ANDROID__ and __linux__, one // may probe for either Linux or Android by simply testing for __linux__. // OTABSL_HAVE_MMAP // // Checks whether the platform has an mmap(2) implementation as defined in // POSIX.1-2001. #ifdef OTABSL_HAVE_MMAP #error OTABSL_HAVE_MMAP cannot be directly set #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \ defined(__ASYLO__) #define OTABSL_HAVE_MMAP 1 #endif // OTABSL_HAVE_PTHREAD_GETSCHEDPARAM // // Checks whether the platform implements the pthread_(get|set)schedparam(3) // functions as defined in POSIX.1-2001. #ifdef OTABSL_HAVE_PTHREAD_GETSCHEDPARAM #error OTABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__ros__) #define OTABSL_HAVE_PTHREAD_GETSCHEDPARAM 1 #endif // OTABSL_HAVE_SCHED_YIELD // // Checks whether the platform implements sched_yield(2) as defined in // POSIX.1-2001. #ifdef OTABSL_HAVE_SCHED_YIELD #error OTABSL_HAVE_SCHED_YIELD cannot be directly set #elif defined(__linux__) || defined(__ros__) || defined(__native_client__) #define OTABSL_HAVE_SCHED_YIELD 1 #endif // OTABSL_HAVE_SEMAPHORE_H // // Checks whether the platform supports the header and sem_init(3) // family of functions as standardized in POSIX.1-2001. // // Note: While Apple provides for both iOS and macOS, it is // explicitly deprecated and will cause build failures if enabled for those // platforms. We side-step the issue by not defining it here for Apple // platforms. #ifdef OTABSL_HAVE_SEMAPHORE_H #error OTABSL_HAVE_SEMAPHORE_H cannot be directly set #elif defined(__linux__) || defined(__ros__) #define OTABSL_HAVE_SEMAPHORE_H 1 #endif // OTABSL_HAVE_ALARM // // Checks whether the platform supports the header and alarm(2) // function as standardized in POSIX.1-2001. #ifdef OTABSL_HAVE_ALARM #error OTABSL_HAVE_ALARM cannot be directly set #elif defined(__GOOGLE_GRTE_VERSION__) // feature tests for Google's GRTE #define OTABSL_HAVE_ALARM 1 #elif defined(__GLIBC__) // feature test for glibc #define OTABSL_HAVE_ALARM 1 #elif defined(_MSC_VER) // feature tests for Microsoft's library #elif defined(__MINGW32__) // mingw32 doesn't provide alarm(2): // https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.2-trunk/mingwrt/include/unistd.h // mingw-w64 provides a no-op implementation: // https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/misc/alarm.c #elif defined(__EMSCRIPTEN__) // emscripten doesn't support signals #elif defined(__Fuchsia__) // Signals don't exist on fuchsia. #elif defined(__native_client__) #else // other standard libraries #define OTABSL_HAVE_ALARM 1 #endif // OTABSL_IS_LITTLE_ENDIAN // OTABSL_IS_BIG_ENDIAN // // Checks the endianness of the platform. // // Notes: uses the built in endian macros provided by GCC (since 4.6) and // Clang (since 3.2); see // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html. // Otherwise, if _WIN32, assume little endian. Otherwise, bail with an error. #if defined(OTABSL_IS_BIG_ENDIAN) #error "OTABSL_IS_BIG_ENDIAN cannot be directly set." #endif #if defined(OTABSL_IS_LITTLE_ENDIAN) #error "OTABSL_IS_LITTLE_ENDIAN cannot be directly set." #endif #if (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define OTABSL_IS_LITTLE_ENDIAN 1 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \ __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define OTABSL_IS_BIG_ENDIAN 1 #elif defined(_WIN32) #define OTABSL_IS_LITTLE_ENDIAN 1 #else #error "absl endian detection needs to be set up for your compiler" #endif // macOS 10.13 and iOS 10.11 don't let you use , , or // even though the headers exist and are publicly noted to work. See // https://github.com/abseil/abseil-cpp/issues/207 and // https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes // libc++ spells out the availability requirements in the file // llvm-project/libcxx/include/__config via the #define // _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS. #if defined(__APPLE__) && defined(_LIBCPP_VERSION) && \ ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101400) || \ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 120000) || \ (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 120000) || \ (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 50000)) #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 1 #else #define OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE 0 #endif // OTABSL_HAVE_STD_ANY // // Checks whether C++17 std::any is available by checking whether exists. #ifdef OTABSL_HAVE_STD_ANY #error "OTABSL_HAVE_STD_ANY cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE #define OTABSL_HAVE_STD_ANY 1 #endif #endif // OTABSL_HAVE_STD_OPTIONAL // // Checks whether C++17 std::optional is available. #ifdef OTABSL_HAVE_STD_OPTIONAL #error "OTABSL_HAVE_STD_OPTIONAL cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE #define OTABSL_HAVE_STD_OPTIONAL 1 #endif #endif // OTABSL_HAVE_STD_VARIANT // // Checks whether C++17 std::variant is available. #ifdef OTABSL_HAVE_STD_VARIANT #error "OTABSL_HAVE_STD_VARIANT cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L && \ !OTABSL_INTERNAL_APPLE_CXX17_TYPES_UNAVAILABLE #define OTABSL_HAVE_STD_VARIANT 1 #endif #endif // OTABSL_HAVE_STD_STRING_VIEW // // Checks whether C++17 std::string_view is available. #ifdef OTABSL_HAVE_STD_STRING_VIEW #error "OTABSL_HAVE_STD_STRING_VIEW cannot be directly set." #endif #ifdef __has_include #if __has_include() && __cplusplus >= 201703L #define OTABSL_HAVE_STD_STRING_VIEW 1 #endif #endif // For MSVC, `__has_include` is supported in VS 2017 15.3, which is later than // the support for , , , . So we use // _MSC_VER to check whether we have VS 2017 RTM (when , , // , is implemented) or higher. Also, `__cplusplus` is // not correctly set by MSVC, so we use `_MSVC_LANG` to check the language // version. // TODO(zhangxy): fix tests before enabling aliasing for `std::any`. #if defined(_MSC_VER) && _MSC_VER >= 1910 && \ ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402) // #define OTABSL_HAVE_STD_ANY 1 #define OTABSL_HAVE_STD_OPTIONAL 1 #define OTABSL_HAVE_STD_VARIANT 1 #define OTABSL_HAVE_STD_STRING_VIEW 1 #endif // OTABSL_USES_STD_ANY // // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is an alias for std::any. #if !defined(OTABSL_OPTION_USE_STD_ANY) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_ANY == 0 || \ (OTABSL_OPTION_USE_STD_ANY == 2 && !defined(OTABSL_HAVE_STD_ANY)) #undef OTABSL_USES_STD_ANY #elif OTABSL_OPTION_USE_STD_ANY == 1 || \ (OTABSL_OPTION_USE_STD_ANY == 2 && defined(OTABSL_HAVE_STD_ANY)) #define OTABSL_USES_STD_ANY 1 #else #error options.h is misconfigured. #endif // OTABSL_USES_STD_OPTIONAL // // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is an alias for std::optional. #if !defined(OTABSL_OPTION_USE_STD_OPTIONAL) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_OPTIONAL == 0 || \ (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && !defined(OTABSL_HAVE_STD_OPTIONAL)) #undef OTABSL_USES_STD_OPTIONAL #elif OTABSL_OPTION_USE_STD_OPTIONAL == 1 || \ (OTABSL_OPTION_USE_STD_OPTIONAL == 2 && defined(OTABSL_HAVE_STD_OPTIONAL)) #define OTABSL_USES_STD_OPTIONAL 1 #else #error options.h is misconfigured. #endif // OTABSL_USES_STD_VARIANT // // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is an alias for std::variant. #if !defined(OTABSL_OPTION_USE_STD_VARIANT) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_VARIANT == 0 || \ (OTABSL_OPTION_USE_STD_VARIANT == 2 && !defined(OTABSL_HAVE_STD_VARIANT)) #undef OTABSL_USES_STD_VARIANT #elif OTABSL_OPTION_USE_STD_VARIANT == 1 || \ (OTABSL_OPTION_USE_STD_VARIANT == 2 && defined(OTABSL_HAVE_STD_VARIANT)) #define OTABSL_USES_STD_VARIANT 1 #else #error options.h is misconfigured. #endif // OTABSL_USES_STD_STRING_VIEW // // Indicates whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is an alias for std::string_view. #if !defined(OTABSL_OPTION_USE_STD_STRING_VIEW) #error options.h is misconfigured. #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 0 || \ (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ !defined(OTABSL_HAVE_STD_STRING_VIEW)) #undef OTABSL_USES_STD_STRING_VIEW #elif OTABSL_OPTION_USE_STD_STRING_VIEW == 1 || \ (OTABSL_OPTION_USE_STD_STRING_VIEW == 2 && \ defined(OTABSL_HAVE_STD_STRING_VIEW)) #define OTABSL_USES_STD_STRING_VIEW 1 #else #error options.h is misconfigured. #endif // In debug mode, MSVC 2017's std::variant throws a EXCEPTION_ACCESS_VIOLATION // SEH exception from emplace for variant when constructing the // struct can throw. This defeats some of variant_test and // variant_exception_safety_test. #if defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_DEBUG) #define OTABSL_INTERNAL_MSVC_2017_DBG_MODE #endif // OTABSL_INTERNAL_MANGLED_NS // OTABSL_INTERNAL_MANGLED_BACKREFERENCE // // Internal macros for building up mangled names in our internal fork of CCTZ. // This implementation detail is only needed and provided for the MSVC build. // // These macros both expand to string literals. OTABSL_INTERNAL_MANGLED_NS is // the mangled spelling of the `absl` namespace, and // OTABSL_INTERNAL_MANGLED_BACKREFERENCE is a back-reference integer representing // the proper count to skip past the CCTZ fork namespace names. (This number // is one larger when there is an inline namespace name to skip.) #if defined(_MSC_VER) #define OTABSL_INTERNAL_MANGLED_NS \ OTABSL_INTERNAL_TOKEN_STR(OTABSL_OPTION_NAMESPACE_NAME) "@absl" #define OTABSL_INTERNAL_MANGLED_BACKREFERENCE "6" #endif #undef OTABSL_INTERNAL_HAS_KEYWORD // OTABSL_DLL // // When building Abseil as a DLL, this macro expands to `__declspec(dllexport)` // so we can annotate symbols appropriately as being exported. When used in // headers consuming a DLL, this macro expands to `__declspec(dllimport)` so // that consumers know the symbol is defined inside the DLL. In all other cases, // the macro expands to nothing. #if defined(_MSC_VER) #if defined(OTABSL_BUILD_DLL) #define OTABSL_DLL __declspec(dllexport) #elif 1 #define OTABSL_DLL __declspec(dllimport) #else #define OTABSL_DLL #endif #else #define OTABSL_DLL #endif // defined(_MSC_VER) #endif // OTABSL_BASE_CONFIG_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/internal/000077500000000000000000000000001474412371400307675ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/internal/identity.h000066400000000000000000000017671474412371400330040ustar00rootroot00000000000000// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef OTABSL_BASE_INTERNAL_IDENTITY_H_ #define OTABSL_BASE_INTERNAL_IDENTITY_H_ #include "../config.h" namespace absl { OTABSL_NAMESPACE_BEGIN namespace internal { template struct identity { typedef T type; }; template using identity_t = typename identity::type; } // namespace internal OTABSL_NAMESPACE_END } // namespace absl #endif // OTABSL_BASE_INTERNAL_IDENTITY_H_ inline_variable.h000066400000000000000000000113741474412371400342120ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/internal// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ #define OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ #include #include "identity.h" // File: // This file define a macro that allows the creation of or emulation of C++17 // inline variables based on whether or not the feature is supported. //////////////////////////////////////////////////////////////////////////////// // Macro: OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) // // Description: // Expands to the equivalent of an inline constexpr instance of the specified // `type` and `name`, initialized to the value `init`. If the compiler being // used is detected as supporting actual inline variables as a language // feature, then the macro expands to an actual inline variable definition. // // Requires: // `type` is a type that is usable in an extern variable declaration. // // Requires: `name` is a valid identifier // // Requires: // `init` is an expression that can be used in the following definition: // constexpr type name = init; // // Usage: // // // Equivalent to: `inline constexpr size_t variant_npos = -1;` // OTABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1); // // Differences in implementation: // For a direct, language-level inline variable, decltype(name) will be the // type that was specified along with const qualification, whereas for // emulated inline variables, decltype(name) may be different (in practice // it will likely be a reference type). //////////////////////////////////////////////////////////////////////////////// #ifdef __cpp_inline_variables // Clang's -Wmissing-variable-declarations option erroneously warned that // inline constexpr objects need to be pre-declared. This has now been fixed, // but we will need to support this workaround for people building with older // versions of clang. // // Bug: https://bugs.llvm.org/show_bug.cgi?id=35862 // // Note: // identity_t is used here so that the const and name are in the // appropriate place for pointer types, reference types, function pointer // types, etc.. #if defined(__clang__) #define OTABSL_INTERNAL_EXTERN_DECL(type, name) \ extern const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name; #else // Otherwise, just define the macro to do nothing. #define OTABSL_INTERNAL_EXTERN_DECL(type, name) #endif // defined(__clang__) // See above comment at top of file for details. #define OTABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \ OTABSL_INTERNAL_EXTERN_DECL(type, name) \ inline constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t name = init #else // See above comment at top of file for details. // // Note: // identity_t is used here so that the const and name are in the // appropriate place for pointer types, reference types, function pointer // types, etc.. #define OTABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \ template \ struct AbslInternalInlineVariableHolder##name { \ static constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t kInstance = init; \ }; \ \ template \ constexpr ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t \ AbslInternalInlineVariableHolder##name::kInstance; \ \ static constexpr const ::absl::OTABSL_OPTION_NAMESPACE_NAME::internal::identity_t& \ name = /* NOLINT */ \ AbslInternalInlineVariableHolder##name<>::kInstance; \ static_assert(sizeof(void (*)(decltype(name))) != 0, \ "Silence unused variable warnings.") #endif // __cpp_inline_variables #endif // OTABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/internal/invoke.h000066400000000000000000000172461474412371400324450ustar00rootroot00000000000000// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::Invoke(f, args...) is an implementation of // INVOKE(f, args...) from section [func.require] of the C++ standard. // // [func.require] // Define INVOKE (f, t1, t2, ..., tN) as follows: // 1. (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T // and t1 is an object of type T or a reference to an object of type T or a // reference to an object of a type derived from T; // 2. ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a // class T and t1 is not one of the types described in the previous item; // 3. t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is // an object of type T or a reference to an object of type T or a reference // to an object of a type derived from T; // 4. (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 // is not one of the types described in the previous item; // 5. f(t1, t2, ..., tN) in all other cases. // // The implementation is SFINAE-friendly: substitution failure within Invoke() // isn't an error. #ifndef OTABSL_BASE_INTERNAL_INVOKE_H_ #define OTABSL_BASE_INTERNAL_INVOKE_H_ #include #include #include #include "../../meta/type_traits.h" // The following code is internal implementation detail. See the comment at the // top of this file for the API documentation. namespace absl { OTABSL_NAMESPACE_BEGIN namespace base_internal { // The five classes below each implement one of the clauses from the definition // of INVOKE. The inner class template Accept checks whether the // clause is applicable; static function template Invoke(f, args...) does the // invocation. // // By separating the clause selection logic from invocation we make sure that // Invoke() does exactly what the standard says. template struct StrippedAccept { template struct Accept : Derived::template AcceptImpl::type>::type...> {}; }; // (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T // and t1 is an object of type T or a reference to an object of type T or a // reference to an object of a type derived from T. struct MemFunAndRef : StrippedAccept { template struct AcceptImpl : std::false_type {}; template struct AcceptImpl : std::integral_constant::value && absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template static decltype((std::declval().* std::declval())(std::declval()...)) Invoke(MemFun&& mem_fun, Obj&& obj, Args&&... args) { return (std::forward(obj).* std::forward(mem_fun))(std::forward(args)...); } }; // ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a // class T and t1 is not one of the types described in the previous item. struct MemFunAndPtr : StrippedAccept { template struct AcceptImpl : std::false_type {}; template struct AcceptImpl : std::integral_constant::value && absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> { }; template static decltype(((*std::declval()).* std::declval())(std::declval()...)) Invoke(MemFun&& mem_fun, Ptr&& ptr, Args&&... args) { return ((*std::forward(ptr)).* std::forward(mem_fun))(std::forward(args)...); } }; // t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is // an object of type T or a reference to an object of type T or a reference // to an object of a type derived from T. struct DataMemAndRef : StrippedAccept { template struct AcceptImpl : std::false_type {}; template struct AcceptImpl : std::integral_constant::value && !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype(std::declval().*std::declval()) Invoke( DataMem&& data_mem, Ref&& ref) { return std::forward(ref).*std::forward(data_mem); } }; // (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 // is not one of the types described in the previous item. struct DataMemAndPtr : StrippedAccept { template struct AcceptImpl : std::false_type {}; template struct AcceptImpl : std::integral_constant::value && !absl::OTABSL_OPTION_NAMESPACE_NAME::is_function::value> {}; template static decltype((*std::declval()).*std::declval()) Invoke( DataMem&& data_mem, Ptr&& ptr) { return (*std::forward(ptr)).*std::forward(data_mem); } }; // f(t1, t2, ..., tN) in all other cases. struct Callable { // Callable doesn't have Accept because it's the last clause that gets picked // when none of the previous clauses are applicable. template static decltype(std::declval()(std::declval()...)) Invoke( F&& f, Args&&... args) { return std::forward(f)(std::forward(args)...); } }; // Resolves to the first matching clause. template struct Invoker { typedef typename std::conditional< MemFunAndRef::Accept::value, MemFunAndRef, typename std::conditional< MemFunAndPtr::Accept::value, MemFunAndPtr, typename std::conditional< DataMemAndRef::Accept::value, DataMemAndRef, typename std::conditional::value, DataMemAndPtr, Callable>::type>::type>:: type>::type type; }; // The result type of Invoke. template using InvokeT = decltype(Invoker::type::Invoke( std::declval(), std::declval()...)); // Invoke(f, args...) is an implementation of INVOKE(f, args...) from section // [func.require] of the C++ standard. template InvokeT Invoke(F&& f, Args&&... args) { return Invoker::type::Invoke(std::forward(f), std::forward(args)...); } } // namespace base_internal OTABSL_NAMESPACE_END } // namespace absl #endif // OTABSL_BASE_INTERNAL_INVOKE_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/macros.h000066400000000000000000000176311474412371400306200ustar00rootroot00000000000000// // Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: macros.h // ----------------------------------------------------------------------------- // // This header file defines the set of language macros used within Abseil code. // For the set of macros used to determine supported compilers and platforms, // see absl/base/config.h instead. // // This code is compiled directly on many platforms, including client // platforms like Windows, Mac, and embedded systems. Before making // any changes here, make sure that you're not breaking any platforms. #ifndef OTABSL_BASE_MACROS_H_ #define OTABSL_BASE_MACROS_H_ #include #include #include "attributes.h" #include "optimization.h" #include "port.h" // OTABSL_ARRAYSIZE() // // Returns the number of elements in an array as a compile-time constant, which // can be used in defining new arrays. If you use this macro on a pointer by // mistake, you will get a compile-time error. #define OTABSL_ARRAYSIZE(array) \ (sizeof(::absl::OTABSL_OPTION_NAMESPACE_NAME::macros_internal::ArraySizeHelper(array))) namespace absl { OTABSL_NAMESPACE_BEGIN namespace macros_internal { // Note: this internal template function declaration is used by OTABSL_ARRAYSIZE. // The function doesn't need a definition, as we only use its type. template auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; } // namespace macros_internal OTABSL_NAMESPACE_END } // namespace absl // kLinkerInitialized // // An enum used only as a constructor argument to indicate that a variable has // static storage duration, and that the constructor should do nothing to its // state. Use of this macro indicates to the reader that it is legal to // declare a static instance of the class, provided the constructor is given // the absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized argument. // // Normally, it is unsafe to declare a static variable that has a constructor or // a destructor because invocation order is undefined. However, if the type can // be zero-initialized (which the loader does for static variables) into a valid // state and the type's destructor does not affect storage, then a constructor // for static initialization can be declared. // // Example: // // Declaration // explicit MyClass(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal:LinkerInitialized x) {} // // // Invocation // static MyClass my_global(absl::OTABSL_OPTION_NAMESPACE_NAME::base_internal::kLinkerInitialized); namespace absl { OTABSL_NAMESPACE_BEGIN namespace base_internal { enum LinkerInitialized { kLinkerInitialized = 0, }; } // namespace base_internal OTABSL_NAMESPACE_END } // namespace absl // OTABSL_FALLTHROUGH_INTENDED // // Annotates implicit fall-through between switch labels, allowing a case to // indicate intentional fallthrough and turn off warnings about any lack of a // `break` statement. The OTABSL_FALLTHROUGH_INTENDED macro should be followed by // a semicolon and can be used in most places where `break` can, provided that // no statements exist between it and the next switch label. // // Example: // // switch (x) { // case 40: // case 41: // if (truth_is_out_there) { // ++x; // OTABSL_FALLTHROUGH_INTENDED; // Use instead of/along with annotations // // in comments // } else { // return x; // } // case 42: // ... // // Notes: when compiled with clang in C++11 mode, the OTABSL_FALLTHROUGH_INTENDED // macro is expanded to the [[clang::fallthrough]] attribute, which is analysed // when performing switch labels fall-through diagnostic // (`-Wimplicit-fallthrough`). See clang documentation on language extensions // for details: // https://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough // // When used with unsupported compilers, the OTABSL_FALLTHROUGH_INTENDED macro // has no effect on diagnostics. In any case this macro has no effect on runtime // behavior and performance of code. #ifdef OTABSL_FALLTHROUGH_INTENDED #error "OTABSL_FALLTHROUGH_INTENDED should not be defined." #endif // TODO(zhangxy): Use c++17 standard [[fallthrough]] macro, when supported. #if defined(__clang__) && defined(__has_warning) #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") #define OTABSL_FALLTHROUGH_INTENDED [[clang::fallthrough]] #endif #elif defined(__GNUC__) && __GNUC__ >= 7 #define OTABSL_FALLTHROUGH_INTENDED [[gnu::fallthrough]] #endif #ifndef OTABSL_FALLTHROUGH_INTENDED #define OTABSL_FALLTHROUGH_INTENDED \ do { \ } while (0) #endif // OTABSL_DEPRECATED() // // Marks a deprecated class, struct, enum, function, method and variable // declarations. The macro argument is used as a custom diagnostic message (e.g. // suggestion of a better alternative). // // Examples: // // class OTABSL_DEPRECATED("Use Bar instead") Foo {...}; // // OTABSL_DEPRECATED("Use Baz() instead") void Bar() {...} // // template // OTABSL_DEPRECATED("Use DoThat() instead") // void DoThis(); // // Every usage of a deprecated entity will trigger a warning when compiled with // clang's `-Wdeprecated-declarations` option. This option is turned off by // default, but the warnings will be reported by clang-tidy. #if defined(__clang__) && __cplusplus >= 201103L #define OTABSL_DEPRECATED(message) __attribute__((deprecated(message))) #endif #ifndef OTABSL_DEPRECATED #define OTABSL_DEPRECATED(message) #endif // OTABSL_BAD_CALL_IF() // // Used on a function overload to trap bad calls: any call that matches the // overload will cause a compile-time error. This macro uses a clang-specific // "enable_if" attribute, as described at // https://clang.llvm.org/docs/AttributeReference.html#enable-if // // Overloads which use this macro should be bracketed by // `#ifdef OTABSL_BAD_CALL_IF`. // // Example: // // int isdigit(int c); // #ifdef OTABSL_BAD_CALL_IF // int isdigit(int c) // OTABSL_BAD_CALL_IF(c <= -1 || c > 255, // "'c' must have the value of an unsigned char or EOF"); // #endif // OTABSL_BAD_CALL_IF #if OTABSL_HAVE_ATTRIBUTE(enable_if) #define OTABSL_BAD_CALL_IF(expr, msg) \ __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) #endif // OTABSL_ASSERT() // // In C++11, `assert` can't be used portably within constexpr functions. // OTABSL_ASSERT functions as a runtime assert but works in C++11 constexpr // functions. Example: // // constexpr double Divide(double a, double b) { // return OTABSL_ASSERT(b != 0), a / b; // } // // This macro is inspired by // https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions/ #if defined(NDEBUG) #define OTABSL_ASSERT(expr) \ (false ? static_cast(expr) : static_cast(0)) #else #define OTABSL_ASSERT(expr) \ (OTABSL_PREDICT_TRUE((expr)) ? static_cast(0) \ : [] { assert(false && #expr); }()) // NOLINT #endif #ifdef OTABSL_HAVE_EXCEPTIONS #define OTABSL_INTERNAL_TRY try #define OTABSL_INTERNAL_CATCH_ANY catch (...) #define OTABSL_INTERNAL_RETHROW do { throw; } while (false) #else // OTABSL_HAVE_EXCEPTIONS #define OTABSL_INTERNAL_TRY if (true) #define OTABSL_INTERNAL_CATCH_ANY else if (false) #define OTABSL_INTERNAL_RETHROW do {} while (false) #endif // OTABSL_HAVE_EXCEPTIONS #endif // OTABSL_BASE_MACROS_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/optimization.h000066400000000000000000000156111474412371400320560ustar00rootroot00000000000000// // Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: optimization.h // ----------------------------------------------------------------------------- // // This header file defines portable macros for performance optimization. #ifndef OTABSL_BASE_OPTIMIZATION_H_ #define OTABSL_BASE_OPTIMIZATION_H_ #include "config.h" // OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION // // Instructs the compiler to avoid optimizing tail-call recursion. Use of this // macro is useful when you wish to preserve the existing function order within // a stack trace for logging, debugging, or profiling purposes. // // Example: // // int f() { // int result = g(); // OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION(); // return result; // } #if defined(__pnacl__) #define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } #elif defined(__clang__) // Clang will not tail call given inline volatile assembly. #define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") #elif defined(__GNUC__) // GCC will not tail call given inline volatile assembly. #define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") #elif defined(_MSC_VER) #include // The __nop() intrinsic blocks the optimisation. #define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop() #else #define OTABSL_BLOCK_TAIL_CALL_OPTIMIZATION() if (volatile int x = 0) { (void)x; } #endif // OTABSL_CACHELINE_SIZE // // Explicitly defines the size of the L1 cache for purposes of alignment. // Setting the cacheline size allows you to specify that certain objects be // aligned on a cacheline boundary with `OTABSL_CACHELINE_ALIGNED` declarations. // (See below.) // // NOTE: this macro should be replaced with the following C++17 features, when // those are generally available: // // * `std::hardware_constructive_interference_size` // * `std::hardware_destructive_interference_size` // // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html // for more information. #if defined(__GNUC__) // Cache line alignment #if defined(__i386__) || defined(__x86_64__) #define OTABSL_CACHELINE_SIZE 64 #elif defined(__powerpc64__) #define OTABSL_CACHELINE_SIZE 128 #elif defined(__aarch64__) // We would need to read special register ctr_el0 to find out L1 dcache size. // This value is a good estimate based on a real aarch64 machine. #define OTABSL_CACHELINE_SIZE 64 #elif defined(__arm__) // Cache line sizes for ARM: These values are not strictly correct since // cache line sizes depend on implementations, not architectures. There // are even implementations with cache line sizes configurable at boot // time. #if defined(__ARM_ARCH_5T__) #define OTABSL_CACHELINE_SIZE 32 #elif defined(__ARM_ARCH_7A__) #define OTABSL_CACHELINE_SIZE 64 #endif #endif #ifndef OTABSL_CACHELINE_SIZE // A reasonable default guess. Note that overestimates tend to waste more // space, while underestimates tend to waste more time. #define OTABSL_CACHELINE_SIZE 64 #endif // OTABSL_CACHELINE_ALIGNED // // Indicates that the declared object be cache aligned using // `OTABSL_CACHELINE_SIZE` (see above). Cacheline aligning objects allows you to // load a set of related objects in the L1 cache for performance improvements. // Cacheline aligning objects properly allows constructive memory sharing and // prevents destructive (or "false") memory sharing. // // NOTE: this macro should be replaced with usage of `alignas()` using // `std::hardware_constructive_interference_size` and/or // `std::hardware_destructive_interference_size` when available within C++17. // // See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0154r1.html // for more information. // // On some compilers, `OTABSL_CACHELINE_ALIGNED` expands to an `__attribute__` // or `__declspec` attribute. For compilers where this is not known to work, // the macro expands to nothing. // // No further guarantees are made here. The result of applying the macro // to variables and types is always implementation-defined. // // WARNING: It is easy to use this attribute incorrectly, even to the point // of causing bugs that are difficult to diagnose, crash, etc. It does not // of itself guarantee that objects are aligned to a cache line. // // NOTE: Some compilers are picky about the locations of annotations such as // this attribute, so prefer to put it at the beginning of your declaration. // For example, // // OTABSL_CACHELINE_ALIGNED static Foo* foo = ... // // class OTABSL_CACHELINE_ALIGNED Bar { ... // // Recommendations: // // 1) Consult compiler documentation; this comment is not kept in sync as // toolchains evolve. // 2) Verify your use has the intended effect. This often requires inspecting // the generated machine code. // 3) Prefer applying this attribute to individual variables. Avoid // applying it to types. This tends to localize the effect. #define OTABSL_CACHELINE_ALIGNED __attribute__((aligned(OTABSL_CACHELINE_SIZE))) #elif defined(_MSC_VER) #define OTABSL_CACHELINE_SIZE 64 #define OTABSL_CACHELINE_ALIGNED __declspec(align(OTABSL_CACHELINE_SIZE)) #else #define OTABSL_CACHELINE_SIZE 64 #define OTABSL_CACHELINE_ALIGNED #endif // OTABSL_PREDICT_TRUE, OTABSL_PREDICT_FALSE // // Enables the compiler to prioritize compilation using static analysis for // likely paths within a boolean branch. // // Example: // // if (OTABSL_PREDICT_TRUE(expression)) { // return result; // Faster if more likely // } else { // return 0; // } // // Compilers can use the information that a certain branch is not likely to be // taken (for instance, a CHECK failure) to optimize for the common case in // the absence of better information (ie. compiling gcc with `-fprofile-arcs`). // // Recommendation: Modern CPUs dynamically predict branch execution paths, // typically with accuracy greater than 97%. As a result, annotating every // branch in a codebase is likely counterproductive; however, annotating // specific branches that are both hot and consistently mispredicted is likely // to yield performance improvements. #if OTABSL_HAVE_BUILTIN(__builtin_expect) || \ (defined(__GNUC__) && !defined(__clang__)) #define OTABSL_PREDICT_FALSE(x) (__builtin_expect(x, 0)) #define OTABSL_PREDICT_TRUE(x) (__builtin_expect(false || (x), true)) #else #define OTABSL_PREDICT_FALSE(x) (x) #define OTABSL_PREDICT_TRUE(x) (x) #endif #endif // OTABSL_BASE_OPTIMIZATION_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/options.h000066400000000000000000000227101474412371400310210ustar00rootroot00000000000000#ifndef OTABSL_BASE_OPTIONS_H_ #define OTABSL_BASE_OPTIONS_H_ // Copyright 2019 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: options.h // ----------------------------------------------------------------------------- // // This file contains Abseil configuration options for setting specific // implementations instead of letting Abseil determine which implementation to // use at compile-time. Setting these options may be useful for package or build // managers who wish to guarantee ABI stability within binary builds (which are // otherwise difficult to enforce). // // *** IMPORTANT NOTICE FOR PACKAGE MANAGERS: It is important that // maintainers of package managers who wish to package Abseil read and // understand this file! *** // // Abseil contains a number of possible configuration endpoints, based on // parameters such as the detected platform, language version, or command-line // flags used to invoke the underlying binary. As is the case with all // libraries, binaries which contain Abseil code must ensure that separate // packages use the same compiled copy of Abseil to avoid a diamond dependency // problem, which can occur if two packages built with different Abseil // configuration settings are linked together. Diamond dependency problems in // C++ may manifest as violations to the One Definition Rule (ODR) (resulting in // linker errors), or undefined behavior (resulting in crashes). // // Diamond dependency problems can be avoided if all packages utilize the same // exact version of Abseil. Building from source code with the same compilation // parameters is the easiest way to avoid such dependency problems. However, for // package managers who cannot control such compilation parameters, we are // providing the file to allow you to inject ABI (Application Binary Interface) // stability across builds. Settings options in this file will neither change // API nor ABI, providing a stable copy of Abseil between packages. // // Care must be taken to keep options within these configurations isolated // from any other dynamic settings, such as command-line flags which could alter // these options. This file is provided specifically to help build and package // managers provide a stable copy of Abseil within their libraries and binaries; // other developers should not have need to alter the contents of this file. // // ----------------------------------------------------------------------------- // Usage // ----------------------------------------------------------------------------- // // For any particular package release, set the appropriate definitions within // this file to whatever value makes the most sense for your package(s). Note // that, by default, most of these options, at the moment, affect the // implementation of types; future options may affect other implementation // details. // // NOTE: the defaults within this file all assume that Abseil can select the // proper Abseil implementation at compile-time, which will not be sufficient // to guarantee ABI stability to package managers. // Include a standard library header to allow configuration based on the // standard library in use. #ifdef __cplusplus #include #endif // ----------------------------------------------------------------------------- // Type Compatibility Options // ----------------------------------------------------------------------------- // // OTABSL_OPTION_USE_STD_ANY // // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::any is implemented as an alias to // std::any, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 // support, and is expected to work on every toolchain we support. // // A value of 1 means to use an alias to std::any. This requires that all code // using Abseil is built in C++17 mode or later. // // A value of 2 means to detect the C++ version being used to compile Abseil, // and use an alias only if a working std::any is available. This option is // useful when you are building your entire program, including all of its // dependencies, from source. It should not be used otherwise -- for example, // if you are distributing Abseil in a binary package manager -- since in // mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::any will name a different type, with a different mangled name // and binary layout, depending on the compiler flags passed by the end user. // For more info, see https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if // absl::OTABSL_OPTION_NAMESPACE_NAME::any is a typedef of std::any, use the feature macro OTABSL_USES_STD_ANY. #define OTABSL_OPTION_USE_STD_ANY 0 // OTABSL_OPTION_USE_STD_OPTIONAL // // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::optional is implemented as an alias to // std::optional, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 // support, and is expected to work on every toolchain we support. // // A value of 1 means to use an alias to std::optional. This requires that all // code using Abseil is built in C++17 mode or later. // // A value of 2 means to detect the C++ version being used to compile Abseil, // and use an alias only if a working std::optional is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary // package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::optional will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // User code should not inspect this macro. To check in the preprocessor if // absl::OTABSL_OPTION_NAMESPACE_NAME::optional is a typedef of std::optional, use the feature macro // OTABSL_USES_STD_OPTIONAL. #define OTABSL_OPTION_USE_STD_OPTIONAL 0 // OTABSL_OPTION_USE_STD_STRING_VIEW // // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is implemented as an alias to // std::string_view, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 // support, and is expected to work on every toolchain we support. // // A value of 1 means to use an alias to std::string_view. This requires that // all code using Abseil is built in C++17 mode or later. // // A value of 2 means to detect the C++ version being used to compile Abseil, // and use an alias only if a working std::string_view is available. This // option is useful when you are building your program from source. It should // not be used otherwise -- for example, if you are distributing Abseil in a // binary package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::string_view will name a // different type, with a different mangled name and binary layout, depending on // the compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if // absl::OTABSL_OPTION_NAMESPACE_NAME::string_view is a typedef of std::string_view, use the feature macro // OTABSL_USES_STD_STRING_VIEW. #define OTABSL_OPTION_USE_STD_STRING_VIEW 0 // OTABSL_OPTION_USE_STD_VARIANT // // This option controls whether absl::OTABSL_OPTION_NAMESPACE_NAME::variant is implemented as an alias to // std::variant, or as an independent implementation. // // A value of 0 means to use Abseil's implementation. This requires only C++11 // support, and is expected to work on every toolchain we support. // // A value of 1 means to use an alias to std::variant. This requires that all // code using Abseil is built in C++17 mode or later. // // A value of 2 means to detect the C++ version being used to compile Abseil, // and use an alias only if a working std::variant is available. This option // is useful when you are building your program from source. It should not be // used otherwise -- for example, if you are distributing Abseil in a binary // package manager -- since in mode 2, absl::OTABSL_OPTION_NAMESPACE_NAME::variant will name a different // type, with a different mangled name and binary layout, depending on the // compiler flags passed by the end user. For more info, see // https://abseil.io/about/design/dropin-types. // // User code should not inspect this macro. To check in the preprocessor if // absl::OTABSL_OPTION_NAMESPACE_NAME::variant is a typedef of std::variant, use the feature macro // OTABSL_USES_STD_VARIANT. #define OTABSL_OPTION_USE_STD_VARIANT 0 // OTABSL_OPTION_NAMESPACE_NAME // // All codes in otabsl are under OTABSL_OPTION_NAMESPACE_NAME, we do not use inline namespace to avoid // conlict with external Abseil. #define OTABSL_OPTION_NAMESPACE_NAME otel_v1 #endif // OTABSL_BASE_OPTIONS_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/policy_checks.h000066400000000000000000000104111474412371400321400ustar00rootroot00000000000000// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: policy_checks.h // ----------------------------------------------------------------------------- // // This header enforces a minimum set of policies at build time, such as the // supported compiler and library versions. Unsupported configurations are // reported with `#error`. This enforcement is best effort, so successfully // compiling this header does not guarantee a supported configuration. #ifndef OTABSL_BASE_POLICY_CHECKS_H_ #define OTABSL_BASE_POLICY_CHECKS_H_ // Included for the __GLIBC_PREREQ macro used below. #include // Included for the _STLPORT_VERSION macro used below. #if defined(__cplusplus) #include #endif // ----------------------------------------------------------------------------- // Operating System Check // ----------------------------------------------------------------------------- #if defined(__CYGWIN__) #error "Cygwin is not supported." #endif // ----------------------------------------------------------------------------- // Compiler Check // ----------------------------------------------------------------------------- #if 0 /* FIXME: MG */ // We support MSVC++ 14.0 update 2 and later. // This minimum will go up. #if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 190023918 && !defined(__clang__) #error "This package requires Visual Studio 2015 Update 2 or higher." #endif #endif // We support gcc 4.7 and later. // This minimum will go up. #if defined(__GNUC__) && !defined(__clang__) #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) #error "This package requires gcc 4.7 or higher." #endif #endif // We support Apple Xcode clang 4.2.1 (version 421.11.65) and later. // This corresponds to Apple Xcode version 4.5. // This minimum will go up. #if defined(__apple_build_version__) && __apple_build_version__ < 4211165 #error "This package requires __apple_build_version__ of 4211165 or higher." #endif // ----------------------------------------------------------------------------- // C++ Version Check // ----------------------------------------------------------------------------- // Enforce C++11 as the minimum. #if defined(_MSVC_LANG) #if _MSVC_LANG < 201103L #error "C++ versions less than C++11 are not supported." #endif // _MSVC_LANG < 201103L #elif defined(__cplusplus) #if __cplusplus < 201103L #error "C++ versions less than C++11 are not supported." #endif // __cplusplus < 201103L #endif // ----------------------------------------------------------------------------- // Standard Library Check // ----------------------------------------------------------------------------- #if defined(_STLPORT_VERSION) #error "STLPort is not supported." #endif // ----------------------------------------------------------------------------- // `char` Size Check // ----------------------------------------------------------------------------- // Abseil currently assumes CHAR_BIT == 8. If you would like to use Abseil on a // platform where this is not the case, please provide us with the details about // your platform so we can consider relaxing this requirement. #if CHAR_BIT != 8 #error "Abseil assumes CHAR_BIT == 8." #endif // ----------------------------------------------------------------------------- // `int` Size Check // ----------------------------------------------------------------------------- // Abseil currently assumes that an int is 4 bytes. If you would like to use // Abseil on a platform where this is not the case, please provide us with the // details about your platform so we can consider relaxing this requirement. #if INT_MAX < 2147483647 #error "Abseil assumes that int is at least 4 bytes. " #endif #endif // OTABSL_BASE_POLICY_CHECKS_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/base/port.h000066400000000000000000000016211474412371400303100ustar00rootroot00000000000000// Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // This files is a forwarding header for other headers containing various // portability macros and functions. // This file is used for both C and C++! #ifndef OTABSL_BASE_PORT_H_ #define OTABSL_BASE_PORT_H_ #include "attributes.h" #include "config.h" #include "optimization.h" #endif // OTABSL_BASE_PORT_H_ opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/meta/000077500000000000000000000000001474412371400271675ustar00rootroot00000000000000opentelemetry-cpp-1.19.0/api/include/opentelemetry/nostd/internal/absl/meta/type_traits.h000066400000000000000000000744101474412371400317150ustar00rootroot00000000000000// // Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // type_traits.h // ----------------------------------------------------------------------------- // // This file contains C++11-compatible versions of standard API // functions for determining the characteristics of types. Such traits can // support type inference, classification, and transformation, as well as // make it easier to write templates based on generic type behavior. // // See https://en.cppreference.com/w/cpp/header/type_traits // // WARNING: use of many of the constructs in this header will count as "complex // template metaprogramming", so before proceeding, please carefully consider // https://google.github.io/styleguide/cppguide.html#Template_metaprogramming // // WARNING: using template metaprogramming to detect or depend on API // features is brittle and not guaranteed. Neither the standard library nor // Abseil provides any guarantee that APIs are stable in the face of template // metaprogramming. Use with caution. #ifndef OTABSL_META_TYPE_TRAITS_H_ #define OTABSL_META_TYPE_TRAITS_H_ #include #include #include #include "../base/config.h" // MSVC constructibility traits do not detect destructor properties and so our // implementations should not use them as a source-of-truth. #if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__) #define OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1 #endif namespace absl { OTABSL_NAMESPACE_BEGIN // Defined and documented later on in this file. template struct is_trivially_destructible; // Defined and documented later on in this file. template struct is_trivially_move_assignable; namespace type_traits_internal { // Silence MSVC warnings about the destructor being defined as deleted. #if defined(_MSC_VER) && !defined(__GNUC__) #pragma warning(push) #pragma warning(disable : 4624) #endif // defined(_MSC_VER) && !defined(__GNUC__) template union SingleMemberUnion { T t; }; // Restore the state of the destructor warning that was silenced above. #if defined(_MSC_VER) && !defined(__GNUC__) #pragma warning(pop) #endif // defined(_MSC_VER) && !defined(__GNUC__) template struct IsTriviallyMoveConstructibleObject : std::integral_constant< bool, std::is_move_constructible< type_traits_internal::SingleMemberUnion>::value && absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyCopyConstructibleObject : std::integral_constant< bool, std::is_copy_constructible< type_traits_internal::SingleMemberUnion>::value && absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible::value> {}; template struct IsTriviallyMoveAssignableReference : std::false_type {}; template struct IsTriviallyMoveAssignableReference : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct IsTriviallyMoveAssignableReference : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable::type {}; template struct VoidTImpl { using type = void; }; //////////////////////////////// // Library Fundamentals V2 TS // //////////////////////////////// // NOTE: The `is_detected` family of templates here differ from the library // fundamentals specification in that for library fundamentals, `Op` is // evaluated as soon as the type `is_detected` undergoes // substitution, regardless of whether or not the `::value` is accessed. That // is inconsistent with all other standard traits and prevents lazy evaluation // in larger contexts (such as if the `is_detected` check is a trailing argument // of a `conjunction`. This implementation opts to instead be lazy in the same // way that the standard traits are (this "defect" of the detection idiom // specifications has been reported). template class Op, class... Args> struct is_detected_impl { using type = std::false_type; }; template