diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 921c088992..a379542c9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,6 +182,45 @@ jobs: run: | (cd ./functional/otlp; ./run_test.sh) + cmake_clang_yaml_config: + name: CMake clang 18 (maintainer mode, yaml config) + runs-on: ubuntu-24.04 + env: + CC: /usr/bin/clang-18 + CXX: /usr/bin/clang++-18 + CXX_STANDARD: '14' + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2 + with: + egress-policy: audit + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: 'recursive' + - name: setup + run: | + sudo -E ./ci/setup_ci_environment.sh + - name: install dependencies + run: | + sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release + - name: run cmake clang (maintainer mode, sync) + run: | + ./ci/do_ci.sh cmake.maintainer.yaml.test + - name: install shelltest + run: sudo apt update && sudo apt-get install -y shelltestrunner + - 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 otlp func test + run: | + (cd ./functional/otlp; ./run_test.sh) + - name: run configuration func test + run: | + (cd ./functional/configuration; ./run_test.sh) + cmake_clang_maintainer_async_test: name: CMake clang 18 (maintainer mode, async) runs-on: ubuntu-24.04 diff --git a/.github/workflows/clang-tidy.yaml b/.github/workflows/clang-tidy.yaml index 31ec43181c..e0a8753974 100644 --- a/.github/workflows/clang-tidy.yaml +++ b/.github/workflows/clang-tidy.yaml @@ -17,9 +17,9 @@ jobs: matrix: include: - cmake_options: all-options-abiv1-preview - warning_limit: 61 + warning_limit: 63 - cmake_options: all-options-abiv2-preview - warning_limit: 61 + warning_limit: 63 steps: - name: Harden the runner (Audit all outbound calls) uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 @@ -49,6 +49,12 @@ jobs: libgtest-dev \ libbenchmark-dev + - name: Install rapidyaml + run: | + sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml" + + - name: Check clang-tidy + run: | if ! command -v clang-tidy &> /dev/null; then echo "clang-tidy could not be found" exit 1 diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml index 82ae7922d9..d2145a680d 100644 --- a/.github/workflows/iwyu.yml +++ b/.github/workflows/iwyu.yml @@ -53,9 +53,15 @@ jobs: llvm-dev \ libclang-dev \ cmake + + - name: Install rapidyaml + run: | + sudo -E ./ci/install_thirdparty.sh --install-dir /usr/local --tags-file third_party_release --packages "ryml" + - name: Install include-what-you-use run: | sudo ./ci/install_iwyu.sh + - name: Prepare CMake env: CC: clang diff --git a/.iwyu.imp b/.iwyu.imp index 123e72f32d..02fc11c194 100644 --- a/.iwyu.imp +++ b/.iwyu.imp @@ -11,6 +11,17 @@ { "include": ["", "private", "", "public"] }, { "include": ["", "private", "", "public"] }, + # Work around for ryml + { "include": ["", "private", "", "public"] }, + + { "include": ["", "private", "", "public"] }, + { "include": ["", "private", "", "public"] }, + { "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 diff --git a/CMakeLists.txt b/CMakeLists.txt index ddc8d9cd83..6b260da0ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,8 @@ endif() option(WITH_ABI_VERSION_1 "ABI version 1" ON) option(WITH_ABI_VERSION_2 "EXPERIMENTAL: ABI version 2 preview" OFF) +option(WITH_CONFIGURATION "EXPERIMENTAL: YAML configuration file" OFF) + # # 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. @@ -349,6 +351,14 @@ if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON) include("${opentelemetry-cpp_SOURCE_DIR}/cmake/nlohmann-json.cmake") endif() +# +# Do we need RapidYaml ? +# + +if((NOT WITH_API_ONLY) AND WITH_CONFIGURATION) + include("${opentelemetry-cpp_SOURCE_DIR}/cmake/ryml.cmake") +endif() + # # Do we need OpenTracing ? # @@ -499,6 +509,7 @@ message(STATUS "WITH_ELASTICSEARCH: ${WITH_ELASTICSEARCH}") message(STATUS "WITH_OPENTRACING: ${WITH_OPENTRACING}") message(STATUS "WITH_ETW: ${WITH_ETW}") message(STATUS "OPENTELEMETRY_BUILD_DLL: ${OPENTELEMETRY_BUILD_DLL}") +message(STATUS "WITH_CONFIGURATION: ${WITH_CONFIGURATION}") message(STATUS "---------------------------------------------") message(STATUS "feature preview options") @@ -580,6 +591,9 @@ if(WITH_OPENTRACING) message( STATUS "opentracing-cpp: ${OpenTracing_VERSION} (${OpenTracing_PROVIDER})") endif() +if(ryml_VERSION) + message(STATUS "ryml: ${ryml_VERSION} (${ryml_PROVIDER})") +endif() message(STATUS "---------------------------------------------") include("${opentelemetry-cpp_SOURCE_DIR}/cmake/otel-install-functions.cmake") diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 71a9a82cbd..bf5c5e8b60 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -171,6 +171,31 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then eval "$MAKE_COMMAND" make test exit 0 +elif [[ "$1" == "cmake.maintainer.yaml.test" ]]; then + cd "${BUILD_DIR}" + rm -rf * + cmake "${CMAKE_OPTIONS[@]}" \ + -DWITH_OTLP_HTTP=ON \ + -DWITH_OTLP_GRPC=ON \ + -DWITH_OTLP_FILE=ON \ + -DWITH_PROMETHEUS=ON \ + -DWITH_EXAMPLES=ON \ + -DWITH_EXAMPLES_HTTP=ON \ + -DWITH_ZIPKIN=ON \ + -DBUILD_W3CTRACECONTEXT_TEST=ON \ + -DWITH_ELASTICSEARCH=ON \ + -DWITH_METRICS_EXEMPLAR_PREVIEW=ON \ + -DWITH_ASYNC_EXPORT_PREVIEW=OFF \ + -DOTELCPP_MAINTAINER_MODE=ON \ + -DWITH_NO_DEPRECATED_CODE=ON \ + -DWITH_OTLP_HTTP_COMPRESSION=ON \ + -DWITH_OTLP_RETRY_PREVIEW=ON \ + -DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \ + -DWITH_CONFIGURATION=ON \ + "${SRC_DIR}" + eval "$MAKE_COMMAND" + make test + exit 0 elif [[ "$1" == "cmake.with_async_export.test" ]]; then cd "${BUILD_DIR}" rm -rf * diff --git a/cmake/ryml.cmake b/cmake/ryml.cmake new file mode 100644 index 0000000000..c246d72afe --- /dev/null +++ b/cmake/ryml.cmake @@ -0,0 +1,30 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# Import the rapidyaml target (ryml::ryml). +# 1. Find an installed ryml package +# 2. Use FetchContent to fetch and build ryml from GitHub + +find_package(ryml QUIET) +set(ryml_PROVIDER "find_package") + +if(NOT ryml_FOUND) + FetchContent_Declare( + "ryml" + GIT_REPOSITORY "https://github.com/biojppm/rapidyaml.git" + GIT_TAG "${ryml_GIT_TAG}" + ) + set(ryml_PROVIDER "fetch_repository") + + set(RYML_ENABLE_TESTING OFF CACHE BOOL "" FORCE) + set(RYML_ENABLE_INSTALL OFF CACHE BOOL "" FORCE) + + FetchContent_MakeAvailable(ryml) + + # Set the ryml_VERSION variable from the git tag. + string(REGEX REPLACE "^v([0-9]+\\.[0-9]+\\.[0-9]+)$" "\\1" ryml_VERSION "${ryml_GIT_TAG}") +endif() + +if(NOT TARGET ryml::ryml) + message(FATAL_ERROR "The required ryml::ryml target was not imported") +endif() diff --git a/cmake/thirdparty-dependency-config.cmake b/cmake/thirdparty-dependency-config.cmake index 42242b0aa8..d8b05a75d7 100644 --- a/cmake/thirdparty-dependency-config.cmake +++ b/cmake/thirdparty-dependency-config.cmake @@ -16,6 +16,7 @@ set(OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED gRPC prometheus-cpp OpenTracing + ryml ) #----------------------------------------------------------------------- @@ -26,7 +27,7 @@ set(OTEL_THIRDPARTY_DEPENDENCIES_SUPPORTED set(OTEL_Protobuf_TARGET_NAMESPACE "protobuf") #----------------------------------------------------------------------- -# Set the find_dependecy search mode - empty is default. Options: cmake default (empty string ""), "MODULE", or "CONFIG" +# Set the find_dependency search mode - empty is default. Options: cmake default (empty string ""), "MODULE", or "CONFIG" # # set(OTEL__SEARCH_MODE "") #----------------------------------------------------------------------- set(OTEL_Threads_SEARCH_MODE "") @@ -37,6 +38,7 @@ set(OTEL_nlohmann_json_SEARCH_MODE "CONFIG") set(OTEL_gRPC_SEARCH_MODE "CONFIG") set(OTEL_prometheus-cpp_SEARCH_MODE "CONFIG") set(OTEL_OpenTracing_SEARCH_MODE "CONFIG") +set(OTEL_ryml_SEARCH_MODE "") # The search mode is set to "CONFIG" for Protobuf versions >= 3.22.0 # to find Protobuf's abseil dependency properly until the FindProtobuf module is updated support the upstream protobuf-config.cmake. @@ -45,4 +47,4 @@ if(DEFINED Protobuf_VERSION AND Protobuf_VERSION VERSION_GREATER_EQUAL 3.22.0) set(OTEL_Protobuf_SEARCH_MODE "CONFIG") else() set(OTEL_Protobuf_SEARCH_MODE "") -endif() \ No newline at end of file +endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b0991c0c8e..0bee685546 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -31,3 +31,7 @@ add_subdirectory(multi_processor) if(WITH_EXAMPLES_HTTP) add_subdirectory(http) endif() + +if(WITH_CONFIGURATION) + add_subdirectory(configuration) +endif() diff --git a/examples/configuration/CMakeLists.txt b/examples/configuration/CMakeLists.txt new file mode 100644 index 0000000000..de65e7dee6 --- /dev/null +++ b/examples/configuration/CMakeLists.txt @@ -0,0 +1,81 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +if(DEFINED OPENTELEMETRY_BUILD_DLL) + add_definitions(-DOPENTELEMETRY_BUILD_IMPORT_DLL) +endif() + +add_executable( + example_yaml + main.cc + custom_sampler.cc + custom_sampler_builder.cc + custom_span_exporter.cc + custom_span_exporter_builder.cc + custom_span_processor.cc + custom_span_processor_builder.cc + custom_push_metric_exporter.cc + custom_push_metric_exporter_builder.cc + custom_pull_metric_exporter.cc + custom_pull_metric_exporter_builder.cc + custom_log_record_exporter.cc + custom_log_record_exporter_builder.cc + custom_log_record_processor.cc + custom_log_record_processor_builder.cc) + +target_link_libraries( + example_yaml ${CMAKE_THREAD_LIBS_INIT} + PRIVATE common_metrics_foo_library + common_logs_foo_library + opentelemetry-cpp::ostream_span_exporter_builder + opentelemetry-cpp::ostream_metrics_exporter_builder + opentelemetry-cpp::ostream_log_record_exporter_builder) + +if(WITH_OTLP_HTTP) + add_definitions(-DOTEL_HAVE_OTLP_HTTP) + target_link_libraries( + example_yaml + PRIVATE opentelemetry-cpp::otlp_http_exporter_builder + opentelemetry-cpp::otlp_http_log_record_exporter_builder + opentelemetry-cpp::otlp_http_metric_exporter_builder) +endif() + +if(WITH_OTLP_GRPC) + add_definitions(-DOTEL_HAVE_OTLP_GRPC) + target_link_libraries( + example_yaml + PRIVATE opentelemetry-cpp::otlp_grpc_exporter_builder + opentelemetry-cpp::otlp_grpc_log_record_exporter_builder + opentelemetry-cpp::otlp_grpc_metrics_exporter_builder) +endif() + +if(WITH_OTLP_FILE) + add_definitions(-DOTEL_HAVE_OTLP_FILE) + target_link_libraries( + example_yaml + PRIVATE opentelemetry-cpp::otlp_file_exporter_builder + opentelemetry-cpp::otlp_file_log_record_exporter_builder + opentelemetry-cpp::otlp_file_metric_exporter_builder) +endif() + +if(WITH_ZIPKIN) + add_definitions(-DOTEL_HAVE_ZIPKIN) + target_link_libraries( + example_yaml PRIVATE opentelemetry-cpp::zipkin_trace_exporter_builder) +endif() + +if(WITH_PROMETHEUS) + add_definitions(-DOTEL_HAVE_PROMETHEUS) + target_link_libraries(example_yaml + PRIVATE opentelemetry-cpp::prometheus_exporter_builder) +endif() + +if(DEFINED OPENTELEMETRY_BUILD_DLL) + target_link_libraries(example_yaml + PRIVATE opentelemetry-cpp::opentelemetry_cpp) +else() + target_link_libraries( + example_yaml + PRIVATE opentelemetry-cpp::configuration opentelemetry-cpp::common + opentelemetry-cpp::trace opentelemetry-cpp::logs) +endif() diff --git a/exporters/ostream/CMakeLists.txt b/exporters/ostream/CMakeLists.txt index 52369ea139..09adf5aaef 100644 --- a/exporters/ostream/CMakeLists.txt +++ b/exporters/ostream/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +# +# opentelemetry_exporter_ostream_span +# + add_library(opentelemetry_exporter_ostream_span src/span_exporter.cc src/span_exporter_factory.cc) @@ -27,6 +31,32 @@ if(BUILD_TESTING) TEST_LIST ostream_span_test) endif() # BUILD_TESTING +# +# opentelemetry_exporter_ostream_span_builder +# + +add_library(opentelemetry_exporter_ostream_span_builder + src/console_span_builder.cc) + +set_target_properties(opentelemetry_exporter_ostream_span_builder + PROPERTIES EXPORT_NAME ostream_span_exporter_builder) +set_target_version(opentelemetry_exporter_ostream_span_builder) + +target_include_directories( + opentelemetry_exporter_ostream_span_builder + PUBLIC "$" + "$") + +target_link_libraries(opentelemetry_exporter_ostream_span_builder + PUBLIC opentelemetry_exporter_ostream_span) + +list(APPEND OPENTELEMETRY_OSTREAM_BUILDER_TARGETS + opentelemetry_exporter_ostream_span_builder) + +# +# opentelemetry_exporter_ostream_metrics +# + add_library(opentelemetry_exporter_ostream_metrics src/metric_exporter.cc src/metric_exporter_factory.cc) set_target_properties(opentelemetry_exporter_ostream_metrics @@ -53,6 +83,30 @@ if(BUILD_TESTING) TEST_LIST ostream_metric_test) endif() +# +# opentelemetry_exporter_ostream_metrics_builder +# + +add_library(opentelemetry_exporter_ostream_metrics_builder + src/console_push_metric_builder.cc) +set_target_properties(opentelemetry_exporter_ostream_metrics_builder + PROPERTIES EXPORT_NAME ostream_metrics_exporter_builder) +set_target_version(opentelemetry_exporter_ostream_metrics_builder) + +target_include_directories( + opentelemetry_exporter_ostream_metrics_builder + PUBLIC "$" + "$") +target_link_libraries(opentelemetry_exporter_ostream_metrics_builder + PUBLIC opentelemetry_exporter_ostream_metrics) + +list(APPEND OPENTELEMETRY_OSTREAM_BUILDER_TARGETS + opentelemetry_exporter_ostream_metrics_builder) + +# +# opentelemetry_exporter_ostream_logs +# + add_library(opentelemetry_exporter_ostream_logs src/log_record_exporter.cc src/log_record_exporter_factory.cc) set_target_properties(opentelemetry_exporter_ostream_logs @@ -66,6 +120,36 @@ target_link_libraries(opentelemetry_exporter_ostream_logs PUBLIC opentelemetry_logs) list(APPEND OPENTELEMETRY_OSTREAM_TARGETS opentelemetry_exporter_ostream_logs) +if(BUILD_TESTING) + add_executable(ostream_log_test test/ostream_log_test.cc) + target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} + opentelemetry_exporter_ostream_logs) + gtest_add_tests( + TARGET ostream_log_test + TEST_PREFIX exporter. + TEST_LIST ostream_log_test) +endif() + +# +# opentelemetry_exporter_ostream_logs_builder +# + +add_library(opentelemetry_exporter_ostream_logs_builder + src/console_log_record_builder.cc) +set_target_properties( + opentelemetry_exporter_ostream_logs_builder + PROPERTIES EXPORT_NAME ostream_log_record_exporter_builder) +set_target_version(opentelemetry_exporter_ostream_logs_builder) + +target_include_directories( + opentelemetry_exporter_ostream_logs_builder + PUBLIC "$" + "$") +target_link_libraries(opentelemetry_exporter_ostream_logs_builder + PUBLIC opentelemetry_exporter_ostream_logs) +list(APPEND OPENTELEMETRY_OSTREAM_BUILDER_TARGETS + opentelemetry_exporter_ostream_logs_builder) + otel_add_component( COMPONENT exporters_ostream @@ -77,14 +161,30 @@ otel_add_component( "include/opentelemetry/exporters" FILES_MATCHING PATTERN - "*.h") + "*.h" + PATTERN + "console_log_record_builder.h" + EXCLUDE + PATTERN + "console_push_metric_builder.h" + EXCLUDE + PATTERN + "console_span_builder.h" + EXCLUDE) -if(BUILD_TESTING) - add_executable(ostream_log_test test/ostream_log_test.cc) - target_link_libraries(ostream_log_test ${GTEST_BOTH_LIBRARIES} - opentelemetry_exporter_ostream_logs) - gtest_add_tests( - TARGET ostream_log_test - TEST_PREFIX exporter. - TEST_LIST ostream_log_test) -endif() +otel_add_component( + COMPONENT + exporters_ostream_builder + TARGETS + ${OPENTELEMETRY_OSTREAM_BUILDER_TARGETS} + FILES_DIRECTORY + "include/opentelemetry/exporters/ostream" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "console_log_record_builder.h" + PATTERN + "console_push_metric_builder.h" + PATTERN + "console_span_builder.h") diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 9ad6d7922d..c2b74262ed 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -7,6 +7,10 @@ else() set(OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE) endif() +# +# opentelemetry_otlp_recordable +# + add_library( opentelemetry_otlp_recordable ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} @@ -31,6 +35,25 @@ target_link_libraries(opentelemetry_otlp_recordable PUBLIC opentelemetry_logs) target_link_libraries(opentelemetry_otlp_recordable PUBLIC opentelemetry_metrics) +# +# opentelemetry_exporter_otlp_builder_utils +# + +add_library(opentelemetry_exporter_otlp_builder_utils + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_builder_utils.cc) + +set_target_properties(opentelemetry_exporter_otlp_builder_utils + PROPERTIES EXPORT_NAME otlp_builder_utils) +set_target_version(opentelemetry_exporter_otlp_builder_utils) + +target_include_directories( + opentelemetry_exporter_otlp_builder_utils + PUBLIC "$" + "$") + +target_link_libraries(opentelemetry_exporter_otlp_builder_utils + PUBLIC opentelemetry_otlp_recordable) + if(WITH_OTLP_GRPC) if(NOT DEFINED grpc_lib_type) message( @@ -42,6 +65,11 @@ if(WITH_OTLP_GRPC) else() set(OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE) endif() + + # + # opentelemetry_exporter_otlp_grpc_client + # + add_library( opentelemetry_exporter_otlp_grpc_client ${OPENTELEMETRY_OTLP_GRPC_CLIENT_LIB_TYPE} src/otlp_grpc_client.cc @@ -78,6 +106,10 @@ if(WITH_OTLP_GRPC) list(APPEND OPENTELEMETRY_OTLP_GRPC_TARGETS opentelemetry_exporter_otlp_grpc_client opentelemetry_proto_grpc) + # + # opentelemetry_exporter_otlp_grpc + # + add_library( opentelemetry_exporter_otlp_grpc ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_exporter.cc @@ -94,6 +126,28 @@ if(WITH_OTLP_GRPC) list(APPEND OPENTELEMETRY_OTLP_GRPC_TARGETS opentelemetry_exporter_otlp_grpc) + # + # opentelemetry_exporter_otlp_grpc_builder + # + + add_library( + opentelemetry_exporter_otlp_grpc_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_span_builder.cc) + + set_target_properties(opentelemetry_exporter_otlp_grpc_builder + PROPERTIES EXPORT_NAME otlp_grpc_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_grpc_builder) + + target_link_libraries(opentelemetry_exporter_otlp_grpc_builder + PUBLIC opentelemetry_exporter_otlp_grpc) + + list(APPEND OPENTELEMETRY_OTLP_GRPC_BUILDER_TARGETS + opentelemetry_exporter_otlp_grpc_builder) + + # + # opentelemetry_exporter_otlp_grpc_log + # + add_library( opentelemetry_exporter_otlp_grpc_log ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_log_record_exporter.cc @@ -112,6 +166,29 @@ if(WITH_OTLP_GRPC) list(APPEND OPENTELEMETRY_OTLP_GRPC_TARGETS opentelemetry_exporter_otlp_grpc_log) + # + # opentelemetry_exporter_otlp_grpc_log_builder + # + + add_library( + opentelemetry_exporter_otlp_grpc_log_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_log_record_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_grpc_log_builder + PROPERTIES EXPORT_NAME otlp_grpc_log_record_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_grpc_log_builder) + + target_link_libraries(opentelemetry_exporter_otlp_grpc_log_builder + PUBLIC opentelemetry_exporter_otlp_grpc_log) + + list(APPEND OPENTELEMETRY_OTLP_GRPC_BUILDER_TARGETS + opentelemetry_exporter_otlp_grpc_log_builder) + + # + # opentelemetry_exporter_otlp_grpc_metrics + # + add_library( opentelemetry_exporter_otlp_grpc_metrics ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_metric_exporter.cc @@ -129,9 +206,34 @@ if(WITH_OTLP_GRPC) list(APPEND OPENTELEMETRY_OTLP_GRPC_TARGETS opentelemetry_exporter_otlp_grpc_metrics) + + # + # opentelemetry_exporter_otlp_grpc_metrics_builder + # + + add_library( + opentelemetry_exporter_otlp_grpc_metrics_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_grpc_push_metric_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_grpc_metrics_builder + PROPERTIES EXPORT_NAME otlp_grpc_metrics_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_grpc_metrics_builder) + + target_link_libraries(opentelemetry_exporter_otlp_grpc_metrics_builder + PUBLIC opentelemetry_exporter_otlp_grpc_metrics) + + list(APPEND OPENTELEMETRY_OTLP_GRPC_BUILDER_TARGETS + opentelemetry_exporter_otlp_grpc_metrics_builder) + endif() if(WITH_OTLP_HTTP) + + # + # opentelemetry_exporter_otlp_http_client + # + add_library( opentelemetry_exporter_otlp_http_client ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http.cc @@ -158,6 +260,10 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_HTTP_TARGETS opentelemetry_exporter_otlp_http_client) + # + # opentelemetry_exporter_otlp_http + # + add_library( opentelemetry_exporter_otlp_http ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_exporter.cc @@ -174,6 +280,30 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_HTTP_TARGETS opentelemetry_exporter_otlp_http) + # + # opentelemetry_exporter_otlp_http_builder + # + + add_library( + opentelemetry_exporter_otlp_http_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_span_builder.cc) + + set_target_properties(opentelemetry_exporter_otlp_http_builder + PROPERTIES EXPORT_NAME otlp_http_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_http_builder) + + target_link_libraries( + opentelemetry_exporter_otlp_http_builder + PUBLIC opentelemetry_exporter_otlp_http + opentelemetry_exporter_otlp_builder_utils) + + list(APPEND OPENTELEMETRY_OTLP_HTTP_BUILDER_TARGETS + opentelemetry_exporter_otlp_http_builder) + + # + # opentelemetry_exporter_otlp_http_log + # + add_library( opentelemetry_exporter_otlp_http_log ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_log_record_exporter.cc @@ -192,6 +322,31 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_HTTP_TARGETS opentelemetry_exporter_otlp_http_log) + # + # opentelemetry_exporter_otlp_http_log_builder + # + + add_library( + opentelemetry_exporter_otlp_http_log_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_log_record_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_http_log_builder + PROPERTIES EXPORT_NAME otlp_http_log_record_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_http_log_builder) + + target_link_libraries( + opentelemetry_exporter_otlp_http_log_builder + PUBLIC opentelemetry_exporter_otlp_http_log + opentelemetry_exporter_otlp_builder_utils) + + list(APPEND OPENTELEMETRY_OTLP_HTTP_BUILDER_TARGETS + opentelemetry_exporter_otlp_http_log_builder) + + # + # opentelemetry_exporter_otlp_http_metric + # + add_library( opentelemetry_exporter_otlp_http_metric ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_metric_exporter.cc @@ -209,9 +364,36 @@ if(WITH_OTLP_HTTP) list(APPEND OPENTELEMETRY_OTLP_HTTP_TARGETS opentelemetry_exporter_otlp_http_metric) + + # + # opentelemetry_exporter_otlp_http_metric_builder + # + + add_library( + opentelemetry_exporter_otlp_http_metric_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_http_push_metric_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_http_metric_builder + PROPERTIES EXPORT_NAME otlp_http_metric_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_http_metric_builder) + + target_link_libraries( + opentelemetry_exporter_otlp_http_metric_builder + PUBLIC opentelemetry_exporter_otlp_http_metric + opentelemetry_exporter_otlp_builder_utils) + + list(APPEND OPENTELEMETRY_OTLP_HTTP_BUILDER_TARGETS + opentelemetry_exporter_otlp_http_metric_builder) + endif() if(WITH_OTLP_FILE) + + # + # opentelemetry_exporter_otlp_file_client + # + add_library(opentelemetry_exporter_otlp_file_client ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_client.cc) set_target_properties(opentelemetry_exporter_otlp_file_client @@ -231,6 +413,10 @@ if(WITH_OTLP_FILE) list(APPEND OPENTELEMETRY_OTLP_FILE_TARGETS opentelemetry_exporter_otlp_file_client) + # + # opentelemetry_exporter_otlp_file + # + add_library( opentelemetry_exporter_otlp_file ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_exporter.cc @@ -247,6 +433,28 @@ if(WITH_OTLP_FILE) list(APPEND OPENTELEMETRY_OTLP_FILE_TARGETS opentelemetry_exporter_otlp_file) + # + # opentelemetry_exporter_otlp_file_builder + # + + add_library( + opentelemetry_exporter_otlp_file_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_span_builder.cc) + + set_target_properties(opentelemetry_exporter_otlp_file_builder + PROPERTIES EXPORT_NAME otlp_file_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_file_builder) + + target_link_libraries(opentelemetry_exporter_otlp_file_builder + PUBLIC opentelemetry_exporter_otlp_file) + + list(APPEND OPENTELEMETRY_OTLP_FILE_BUILDER_TARGETS + opentelemetry_exporter_otlp_file_builder) + + # + # opentelemetry_exporter_otlp_file_log + # + add_library( opentelemetry_exporter_otlp_file_log ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_log_record_exporter.cc @@ -265,6 +473,29 @@ if(WITH_OTLP_FILE) list(APPEND OPENTELEMETRY_OTLP_FILE_TARGETS opentelemetry_exporter_otlp_file_log) + # + # opentelemetry_exporter_otlp_file_log_builder + # + + add_library( + opentelemetry_exporter_otlp_file_log_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_log_record_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_file_log_builder + PROPERTIES EXPORT_NAME otlp_file_log_record_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_file_log_builder) + + target_link_libraries(opentelemetry_exporter_otlp_file_log_builder + PUBLIC opentelemetry_exporter_otlp_file_log) + + list(APPEND OPENTELEMETRY_OTLP_FILE_BUILDER_TARGETS + opentelemetry_exporter_otlp_file_log_builder) + + # + # opentelemetry_exporter_otlp_file_metric + # + add_library( opentelemetry_exporter_otlp_file_metric ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_metric_exporter.cc @@ -282,6 +513,26 @@ if(WITH_OTLP_FILE) list(APPEND OPENTELEMETRY_OTLP_FILE_TARGETS opentelemetry_exporter_otlp_file_metric) + + # + # opentelemetry_exporter_otlp_file_metric_builder + # + + add_library( + opentelemetry_exporter_otlp_file_metric_builder + ${OPENTELEMETRY_OTLP_TARGETS_LIB_TYPE} src/otlp_file_push_metric_builder.cc) + + set_target_properties( + opentelemetry_exporter_otlp_file_metric_builder + PROPERTIES EXPORT_NAME otlp_file_metric_exporter_builder) + set_target_version(opentelemetry_exporter_otlp_file_metric_builder) + + target_link_libraries(opentelemetry_exporter_otlp_file_metric_builder + PUBLIC opentelemetry_exporter_otlp_file_metric) + + list(APPEND OPENTELEMETRY_OTLP_FILE_BUILDER_TARGETS + opentelemetry_exporter_otlp_file_metric_builder) + endif() target_link_libraries( @@ -302,6 +553,9 @@ otel_add_component( PATTERN "*.h" PATTERN + "otlp_builder_utils*.h" + EXCLUDE + PATTERN "otlp_http*.h" EXCLUDE PATTERN @@ -311,6 +565,19 @@ otel_add_component( "otlp_file*.h" EXCLUDE) +otel_add_component( + COMPONENT + exporter_otlp_builder_utils + TARGETS + opentelemetry_exporter_otlp_builder_utils + FILES_DIRECTORY + "include/opentelemetry/exporters/otlp" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "otlp_builder_utils.h") + if(WITH_OTLP_GRPC) otel_add_component( COMPONENT @@ -323,7 +590,34 @@ if(WITH_OTLP_GRPC) "include/opentelemetry/exporters" FILES_MATCHING PATTERN - "otlp_grpc*.h") + "otlp_grpc*.h" + PATTERN + "otlp_grpc_span_builder.h" + EXCLUDE + PATTERN + "otlp_grpc_log_record_builder.h" + EXCLUDE + PATTERN + "otlp_grpc_push_metric_builder.h" + EXCLUDE) + + otel_add_component( + COMPONENT + exporters_otlp_grpc_builder + TARGETS + ${OPENTELEMETRY_OTLP_GRPC_BUILDER_TARGETS} + FILES_DIRECTORY + "include/opentelemetry/exporters/otlp" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "otlp_grpc_span_builder.h" + PATTERN + "otlp_grpc_log_record_builder.h" + PATTERN + "otlp_grpc_push_metric_builder.h") + endif() if(WITH_OTLP_HTTP) @@ -338,7 +632,34 @@ if(WITH_OTLP_HTTP) "include/opentelemetry/exporters" FILES_MATCHING PATTERN - "otlp_http*.h") + "otlp_http*.h" + PATTERN + "otlp_http_span_builder.h" + EXCLUDE + PATTERN + "otlp_http_log_record_builder.h" + EXCLUDE + PATTERN + "otlp_http_push_metric_builder.h" + EXCLUDE) + + otel_add_component( + COMPONENT + exporters_otlp_http_builder + TARGETS + ${OPENTELEMETRY_OTLP_HTTP_BUILDER_TARGETS} + FILES_DIRECTORY + "include/opentelemetry/exporters/otlp" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "otlp_http_span_builder.h" + PATTERN + "otlp_http_log_record_builder.h" + PATTERN + "otlp_http_push_metric_builder.h") + endif() if(WITH_OTLP_FILE) @@ -353,7 +674,34 @@ if(WITH_OTLP_FILE) "include/opentelemetry/exporters" FILES_MATCHING PATTERN - "otlp_file*.h") + "otlp_file*.h" + PATTERN + "otlp_file_span_builder.h" + EXCLUDE + PATTERN + "otlp_file_log_record_builder.h" + EXCLUDE + PATTERN + "otlp_file_push_metric_builder.h" + EXCLUDE) + + otel_add_component( + COMPONENT + exporters_otlp_file_builder + TARGETS + ${OPENTELEMETRY_OTLP_FILE_BUILDER_TARGETS} + FILES_DIRECTORY + "include/opentelemetry/exporters/otlp" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "otlp_file_span_builder.h" + PATTERN + "otlp_file_log_record_builder.h" + PATTERN + "otlp_file_push_metric_builder.h") + endif() if(BUILD_TESTING) diff --git a/exporters/prometheus/CMakeLists.txt b/exporters/prometheus/CMakeLists.txt index d6eb288b9b..8b9e974169 100644 --- a/exporters/prometheus/CMakeLists.txt +++ b/exporters/prometheus/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +# +# opentelemetry_exporter_prometheus +# + add_library( opentelemetry_exporter_prometheus src/exporter.cc src/exporter_options.cc src/exporter_factory.cc @@ -20,6 +24,25 @@ target_link_libraries( PUBLIC opentelemetry_metrics prometheus-cpp::core PRIVATE prometheus-cpp::pull) +# +# opentelemetry_exporter_prometheus_builder +# + +add_library(opentelemetry_exporter_prometheus_builder + src/prometheus_pull_builder.cc) + +set_target_properties(opentelemetry_exporter_prometheus_builder + PROPERTIES EXPORT_NAME prometheus_exporter_builder) +set_target_version(opentelemetry_exporter_prometheus_builder) + +target_include_directories( + opentelemetry_exporter_prometheus_builder + PUBLIC "$" + "$") + +target_link_libraries(opentelemetry_exporter_prometheus_builder + PUBLIC opentelemetry_exporter_prometheus) + otel_add_component( COMPONENT exporters_prometheus @@ -31,7 +54,23 @@ otel_add_component( "include/opentelemetry/exporters" FILES_MATCHING PATTERN - "*.h") + "*.h" + PATTERN + "prometheus_pull_builder.h" + EXCLUDE) + +otel_add_component( + COMPONENT + exporters_prometheus_builder + TARGETS + opentelemetry_exporter_prometheus_builder + FILES_DIRECTORY + "include/opentelemetry/exporters/prometheus" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "prometheus_pull_builder.h") if(BUILD_TESTING) add_subdirectory(test) diff --git a/exporters/zipkin/CMakeLists.txt b/exporters/zipkin/CMakeLists.txt index 9fc92ba7a5..c8e3e9be2f 100644 --- a/exporters/zipkin/CMakeLists.txt +++ b/exporters/zipkin/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +# +# opentelemetry_exporter_zipkin_trace +# + add_library( opentelemetry_exporter_zipkin_trace src/zipkin_exporter.cc src/zipkin_exporter_factory.cc src/recordable.cc) @@ -20,6 +24,25 @@ target_link_libraries( PUBLIC opentelemetry_trace opentelemetry_http_client_curl nlohmann_json::nlohmann_json) +# +# opentelemetry_exporter_zipkin_trace_builder +# + +add_library(opentelemetry_exporter_zipkin_trace_builder src/zipkin_builder.cc) + +target_include_directories( + opentelemetry_exporter_zipkin_trace_builder + PUBLIC "$" + "$") + +set_target_properties(opentelemetry_exporter_zipkin_trace_builder + PROPERTIES EXPORT_NAME zipkin_trace_exporter_builder) + +set_target_version(opentelemetry_exporter_zipkin_trace_builder) + +target_link_libraries(opentelemetry_exporter_zipkin_trace_builder + PUBLIC opentelemetry_exporter_zipkin_trace) + otel_add_component( COMPONENT exporters_zipkin @@ -34,8 +57,24 @@ otel_add_component( "*.h" PATTERN "recordable.h" + EXCLUDE + PATTERN + "zipkin_builder.h" EXCLUDE) +otel_add_component( + COMPONENT + exporters_zipkin_builder + TARGETS + opentelemetry_exporter_zipkin_trace_builder + FILES_DIRECTORY + "include/opentelemetry/exporters/zipkin" + FILES_DESTINATION + "include/opentelemetry/exporters" + FILES_MATCHING + PATTERN + "zipkin_builder.h") + if(BUILD_TESTING) add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) diff --git a/install/cmake/CMakeLists.txt b/install/cmake/CMakeLists.txt index d6785a46b5..923873d876 100644 --- a/install/cmake/CMakeLists.txt +++ b/install/cmake/CMakeLists.txt @@ -464,3 +464,21 @@ if(prometheus-cpp IN_LIST _THIRDPARTY_PACKAGE_LIST) add_dependencies(prometheus-cpp-build zlib-install curl-install) endif() + +# ------------------------------------------------------------------------ +# ---- ryml ---- +if(ryml IN_LIST _THIRDPARTY_PACKAGE_LIST) + if(NOT ryml_GIT_TAG) + message(FATAL_ERROR "ryml_GIT_TAG is not set") + endif() + + ExternalProject_Add( + ryml + STEP_TARGETS install + GIT_REPOSITORY "https://github.com/biojppm/rapidyaml.git" + GIT_TAG ${ryml_GIT_TAG} + GIT_SHALLOW ON + PREFIX ${CMAKE_BINARY_DIR}/external/ryml + INSTALL_DIR ${CMAKE_INSTALL_PREFIX} + CMAKE_ARGS "${CMAKE_OPTIONS}") +endif() diff --git a/install/cmake/third_party_latest b/install/cmake/third_party_latest index 3c86596928..ab5db77c2e 100644 --- a/install/cmake/third_party_latest +++ b/install/cmake/third_party_latest @@ -16,3 +16,4 @@ nlohmann-json=v3.12.0 opentelemetry-proto=v1.7.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.3.0 +ryml=v0.9.0 diff --git a/install/cmake/third_party_minimum b/install/cmake/third_party_minimum index 15470c56ac..bca728cf21 100644 --- a/install/cmake/third_party_minimum +++ b/install/cmake/third_party_minimum @@ -18,3 +18,4 @@ nlohmann-json=v3.10.5 opentelemetry-proto=v1.6.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.1.0 +ryml=v0.9.0 diff --git a/install/cmake/third_party_stable b/install/cmake/third_party_stable index 9201ee4f10..7864bb5e31 100644 --- a/install/cmake/third_party_stable +++ b/install/cmake/third_party_stable @@ -16,3 +16,4 @@ nlohmann-json=v3.11.3 opentelemetry-proto=v1.6.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.3.0 +ryml=v0.9.0 diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt index 8e508cfca5..250de63b99 100644 --- a/sdk/CMakeLists.txt +++ b/sdk/CMakeLists.txt @@ -14,17 +14,26 @@ target_link_libraries(opentelemetry_sdk INTERFACE opentelemetry_api) set(OTEL_SDK_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(src) -otel_add_component( - COMPONENT - sdk - TARGETS +list( + APPEND + OPENTELEMETRY_SDK_TARGETS opentelemetry_sdk opentelemetry_common opentelemetry_resources opentelemetry_version opentelemetry_logs opentelemetry_trace - opentelemetry_metrics + opentelemetry_metrics) + +if(WITH_CONFIGURATION) + list(APPEND OPENTELEMETRY_SDK_TARGETS opentelemetry_configuration) +endif() + +otel_add_component( + COMPONENT + sdk + TARGETS + ${OPENTELEMETRY_SDK_TARGETS} FILES_DIRECTORY "include/opentelemetry/" FILES_DESTINATION diff --git a/sdk/src/CMakeLists.txt b/sdk/src/CMakeLists.txt index 377d305627..c922726547 100644 --- a/sdk/src/CMakeLists.txt +++ b/sdk/src/CMakeLists.txt @@ -7,3 +7,7 @@ add_subdirectory(metrics) add_subdirectory(logs) add_subdirectory(version) add_subdirectory(resource) + +if(WITH_CONFIGURATION) + add_subdirectory(configuration) +endif() diff --git a/sdk/src/configuration/CMakeLists.txt b/sdk/src/configuration/CMakeLists.txt new file mode 100644 index 0000000000..0cfb3d67ac --- /dev/null +++ b/sdk/src/configuration/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +add_library( + opentelemetry_configuration + configuration_parser.cc + document_node.cc + yaml_configuration_parser.cc + ryml_document.cc + ryml_document_node.cc + configured_sdk.cc + sdk_builder.cc + registry.cc) + +set_target_properties(opentelemetry_configuration PROPERTIES EXPORT_NAME + configuration) +set_target_version(opentelemetry_configuration) + +target_include_directories( + opentelemetry_configuration + PUBLIC "$" + "$") + +target_link_libraries( + opentelemetry_configuration + PUBLIC opentelemetry_api opentelemetry_common opentelemetry_trace + opentelemetry_metrics opentelemetry_logs + PRIVATE ryml::ryml) + +if(OPENTELEMETRY_INSTALL) + opentelemetry_add_pkgconfig( + configuration "OpenTelemetry SDK - Configuration" + "Components for exporting traces in the OpenTelemetry SDK." + "opentelemetry_configuration") +endif() diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index fbdd109435..4cc2f53a6c 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include #include #include #include diff --git a/sdk/src/configuration/sdk_builder.cc b/sdk/src/configuration/sdk_builder.cc index ecbf9c4165..a00b181890 100644 --- a/sdk/src/configuration/sdk_builder.cc +++ b/sdk/src/configuration/sdk_builder.cc @@ -180,8 +180,8 @@ class ResourceAttributeValueSetter void VisitString( const opentelemetry::sdk::configuration::StringAttributeValueConfiguration *model) override { - opentelemetry::common::AttributeValue attribute_value(model->value); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(model->value); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitInteger( @@ -189,22 +189,22 @@ class ResourceAttributeValueSetter { /* Provide exact type to opentelemetry::common::AttributeValue variant. */ int64_t value = model->value; - opentelemetry::common::AttributeValue attribute_value(value); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(value); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitDouble( const opentelemetry::sdk::configuration::DoubleAttributeValueConfiguration *model) override { - opentelemetry::common::AttributeValue attribute_value(model->value); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(model->value); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitBoolean( const opentelemetry::sdk::configuration::BooleanAttributeValueConfiguration *model) override { - opentelemetry::common::AttributeValue attribute_value(model->value); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(model->value); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitStringArray( @@ -224,8 +224,8 @@ class ResourceAttributeValueSetter nostd::span span(string_view_array.data(), string_view_array.size()); - opentelemetry::common::AttributeValue attribute_value(span); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(span); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitIntegerArray( @@ -245,8 +245,8 @@ class ResourceAttributeValueSetter nostd::span span(int_array.data(), int_array.size()); - opentelemetry::common::AttributeValue attribute_value(span); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(span); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitDoubleArray( @@ -259,8 +259,8 @@ class ResourceAttributeValueSetter nostd::span span(model->value.data(), model->value.size()); - opentelemetry::common::AttributeValue attribute_value(span); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(span); + resource_attributes_.SetAttribute(name_, attr_value); } void VisitBooleanArray( @@ -283,8 +283,8 @@ class ResourceAttributeValueSetter nostd::span span(&bool_array[0], length); - opentelemetry::common::AttributeValue attribute_value(span); - resource_attributes_.SetAttribute(name_, attribute_value); + opentelemetry::common::AttributeValue attr_value(span); + resource_attributes_.SetAttribute(name_, attr_value); } opentelemetry::common::AttributeValue attribute_value; @@ -711,12 +711,8 @@ std::unique_ptr SdkBuilder::CreateAlwaysOnSa std::unique_ptr SdkBuilder::CreateJaegerRemoteSampler( const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration * /* model */) const { - std::unique_ptr sdk; - static const std::string die("JaegerRemoteSampler not supported"); throw UnsupportedException(die); - - return sdk; } std::unique_ptr SdkBuilder::CreateParentBasedSampler( @@ -1155,7 +1151,6 @@ static opentelemetry::sdk::metrics::InstrumentType ConvertInstrumentType( switch (config) { - case opentelemetry::sdk::configuration::InstrumentType::none: case opentelemetry::sdk::configuration::InstrumentType::counter: sdk = opentelemetry::sdk::metrics::InstrumentType::kCounter; break; @@ -1174,6 +1169,10 @@ static opentelemetry::sdk::metrics::InstrumentType ConvertInstrumentType( case opentelemetry::sdk::configuration::InstrumentType::up_down_counter: sdk = opentelemetry::sdk::metrics::InstrumentType::kUpDownCounter; break; + case opentelemetry::sdk::configuration::InstrumentType::none: + default: + sdk = opentelemetry::sdk::metrics::InstrumentType::kCounter; + break; } return sdk; diff --git a/sdk/test/CMakeLists.txt b/sdk/test/CMakeLists.txt index 33dd07f81a..dd957fae1f 100644 --- a/sdk/test/CMakeLists.txt +++ b/sdk/test/CMakeLists.txt @@ -7,3 +7,7 @@ add_subdirectory(metrics) add_subdirectory(logs) add_subdirectory(resource) add_subdirectory(instrumentationscope) + +if(WITH_CONFIGURATION) + add_subdirectory(configuration) +endif() diff --git a/sdk/test/configuration/CMakeLists.txt b/sdk/test/configuration/CMakeLists.txt new file mode 100644 index 0000000000..e34942dff6 --- /dev/null +++ b/sdk/test/configuration/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +foreach(testname yaml_logs_test yaml_metrics_test yaml_propagator_test + yaml_resource_test yaml_test yaml_trace_test) + add_executable(${testname} "${testname}.cc") + target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_configuration) + gtest_add_tests( + TARGET ${testname} + TEST_PREFIX trace. + TEST_LIST ${testname}) +endforeach() diff --git a/test_common/cmake/preview-options.cmake b/test_common/cmake/preview-options.cmake index 41a35aa55b..f6c3e90f5e 100644 --- a/test_common/cmake/preview-options.cmake +++ b/test_common/cmake/preview-options.cmake @@ -16,3 +16,4 @@ set(WITH_OTLP_RETRY_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE) set(WITH_RESOURCE_DETECTORS_PREVIEW ${ENABLE_PREVIEW} CACHE BOOL "" FORCE) set(WITH_OTLP_HTTP_COMPRESSION ${ENABLE_PREVIEW} CACHE BOOL "" FORCE) set(WITH_CURL_LOGGING ${ENABLE_PREVIEW} CACHE BOOL "" FORCE) +set(WITH_CONFIGURATION ${ENABLE_PREVIEW} CACHE BOOL "" FORCE) diff --git a/third_party_release b/third_party_release index 93b6ce47a5..7f7194a23b 100644 --- a/third_party_release +++ b/third_party_release @@ -27,3 +27,4 @@ opentelemetry-proto=v1.7.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.3.0 vcpkg=2024.02.14 +ryml=v0.9.0 diff --git a/tools/format.sh b/tools/format.sh index d551ab21dd..a83ff53293 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -23,8 +23,8 @@ fi # No CRLF line endings, except Windows files. "${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \ -name '*.cmd' -prune -o -type f -print) -# No trailing spaces, except in patch, yaml and shelltest. -"${SED[@]}" 's/ \+$//' $($FIND -name "*.patch" -prune -o -name "*.yaml" -prune -o -name "*.test" -prune -o -type f -print) +# No trailing spaces, except in diff, patch and shelltest. +"${SED[@]}" 's/ \+$//' $($FIND -name "*.diff" -prune -o -name "*.patch" -prune -o -name "*.test" -prune -o -type f -print) # If not overridden, try to use clang-format-18 or clang-format. if [[ -z "$CLANG_FORMAT" ]]; then