diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eceb182571..bb612fc3a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: sudo -E ./ci/setup_cmake.sh sudo -E ./ci/setup_ci_environment.sh sudo -E ./ci/install_protobuf.sh - sudo -E ./ci/install_yaml_cpp.sh + sudo -E ./ci/install_ryml.sh - name: run cmake clang (maintainer mode, sync) env: CC: /usr/bin/clang-15 diff --git a/CMakeLists.txt b/CMakeLists.txt index fdfe1c2f78..8878b86c1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,8 +95,7 @@ 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: configuration model" OFF) -option(WITH_CONFIGURATION_YAML "EXPERIMENTAL: YAML configuration file" OFF) +option(WITH_CONFIGURATION "EXPERIMENTAL: YAML configuration file" OFF) file(READ "${CMAKE_CURRENT_LIST_DIR}/api/include/opentelemetry/version.h" OPENTELEMETRY_CPP_HEADER_VERSION_H) @@ -287,10 +286,6 @@ option(WITH_METRICS_EXEMPLAR_PREVIEW # Verify options dependencies # -if(WITH_CONFIGURATION_YAML AND NOT WITH_CONFIGURATION) - message(FATAL_ERROR "CONFIGURATION_YAML=ON requires WITH_CONFIGURATION=ON") -endif() - if(WITH_EXAMPLES_HTTP AND NOT WITH_EXAMPLES) message(FATAL_ERROR "WITH_EXAMPLES_HTTP=ON requires WITH_EXAMPLES=ON") endif() @@ -473,8 +468,18 @@ if((NOT WITH_API_ONLY) AND USE_NLOHMANN_JSON) include(cmake/nlohmann-json.cmake) endif() -find_package(yaml-cpp REQUIRED) -find_package(ryml REQUIRED) +# +# Do we need RapidYaml ? +# + +if((NOT WITH_API_ONLY) AND WITH_CONFIGURATION) + # No specific version required. + find_package(ryml REQUIRED) + message(STATUS "Found ryml: include ${RYML_INCLUDE_DIR}, lib ${RYML_LIB_DIR}, version ${ryml_VERSION}") +endif() + +# DEAD +# find_package(yaml-cpp REQUIRED) if(OTELCPP_MAINTAINER_MODE) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/ci/install_ryml.sh b/ci/install_ryml.sh new file mode 100755 index 0000000000..dfa1ba20a5 --- /dev/null +++ b/ci/install_ryml.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +set -ex +export DEBIAN_FRONTEND=noninteractive +[ -z "${RYML_VERSION}" ] && export RYML_VERSION="0.5.0" + +BUILD_DIR=/tmp/ +INSTALL_DIR=/usr/local/ +pushd $BUILD_DIR +git clone --recursive -b ${RYML_VERSION} https://github.com/biojppm/rapidyaml.git +cd yaml-cpp +RYML_BUILD_OPTIONS=( + "-DBUILD_TESTING=OFF" + "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" + "-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR" +) + +if [ ! -z "${CXX_STANDARD}" ]; then + RYML_BUILD_OPTIONS=(${RYML_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}") +fi + +mkdir build && pushd build +cmake ${RYML_BUILD_OPTIONS[@]} .. +make -j $(nproc) +make install +popd +popd +export PATH=${INSTALL_DIR}/bin:$PATH # ensure to use the installed ryml diff --git a/sdk/include/opentelemetry/sdk/configuration/invalid_schema_exception.h b/sdk/include/opentelemetry/sdk/configuration/invalid_schema_exception.h index 7fbe31493d..e17cf42341 100644 --- a/sdk/include/opentelemetry/sdk/configuration/invalid_schema_exception.h +++ b/sdk/include/opentelemetry/sdk/configuration/invalid_schema_exception.h @@ -3,7 +3,6 @@ #pragma once -#include #include #include "opentelemetry/sdk/configuration/document.h" diff --git a/sdk/src/CMakeLists.txt b/sdk/src/CMakeLists.txt index d46c5b005f..67fac35208 100644 --- a/sdk/src/CMakeLists.txt +++ b/sdk/src/CMakeLists.txt @@ -7,5 +7,8 @@ add_subdirectory(metrics) add_subdirectory(logs) add_subdirectory(version) add_subdirectory(resource) -add_subdirectory(configuration) -add_subdirectory(init) + +if(WITH_CONFIGURATION) + add_subdirectory(configuration) + add_subdirectory(init) +endif() diff --git a/sdk/src/configuration/CMakeLists.txt b/sdk/src/configuration/CMakeLists.txt index 05aae825de..c9292dee58 100644 --- a/sdk/src/configuration/CMakeLists.txt +++ b/sdk/src/configuration/CMakeLists.txt @@ -1,10 +1,13 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 +# DEAD +# yaml_document.cc yaml_document_node.cc + add_library( opentelemetry_configuration configuration_factory.cc - yaml_configuration_factory.cc yaml_document.cc yaml_document_node.cc + yaml_configuration_factory.cc ryml_document.cc ryml_document_node.cc) set_target_properties(opentelemetry_configuration PROPERTIES EXPORT_NAME configuration) @@ -18,10 +21,9 @@ target_link_libraries( opentelemetry_configuration PUBLIC opentelemetry_api opentelemetry_common) -target_link_libraries( - opentelemetry_configuration - PUBLIC yaml-cpp::yaml-cpp) - +# target_link_libraries( +# opentelemetry_configuration +# PUBLIC yaml-cpp::yaml-cpp) target_link_libraries( opentelemetry_configuration diff --git a/sdk/src/configuration/configuration_factory.cc b/sdk/src/configuration/configuration_factory.cc index 7a1f384994..4ec74094b5 100644 --- a/sdk/src/configuration/configuration_factory.cc +++ b/sdk/src/configuration/configuration_factory.cc @@ -1,7 +1,6 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include #include #include "opentelemetry/sdk/common/global_log_handler.h" @@ -27,7 +26,6 @@ #include "opentelemetry/sdk/configuration/simple_propagator_configuration.h" #include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h" #include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h" -#include "opentelemetry/sdk/configuration/yaml_document.h" #include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" #include "opentelemetry/version.h" diff --git a/sdk/src/configuration/yaml_configuration_factory.cc b/sdk/src/configuration/yaml_configuration_factory.cc index 8d0486eb5d..a11dd02ce4 100644 --- a/sdk/src/configuration/yaml_configuration_factory.cc +++ b/sdk/src/configuration/yaml_configuration_factory.cc @@ -1,9 +1,10 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -#include #include +// #define WITH_YAML_CPP + #include "opentelemetry/sdk/common/global_log_handler.h" #include "opentelemetry/sdk/configuration/configuration.h" @@ -11,10 +12,13 @@ #include "opentelemetry/sdk/configuration/ryml_document.h" #include "opentelemetry/sdk/configuration/ryml_document_node.h" #include "opentelemetry/sdk/configuration/yaml_configuration_factory.h" -#include "opentelemetry/sdk/configuration/yaml_document.h" -#include "opentelemetry/sdk/configuration/yaml_document_node.h" #include "opentelemetry/version.h" +#ifdef WITH_YAML_CPP +# include "opentelemetry/sdk/configuration/yaml_document.h" +# include "opentelemetry/sdk/configuration/yaml_document_node.h" +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk { @@ -39,6 +43,7 @@ std::unique_ptr YamlConfigurationFactory::ParseFile(std::string f return conf; } +#ifdef WITH_YAML_CPP static std::unique_ptr YamlCppParse(const std::string &content) { std::unique_ptr doc; @@ -60,6 +65,7 @@ static std::unique_ptr YamlCppParse(const std::string &content) return doc; } +#endif static std::unique_ptr RymlParse(const std::string &content) { @@ -84,8 +90,6 @@ std::unique_ptr YamlConfigurationFactory::ParseString(std::string std::unique_ptr root; std::unique_ptr config; - // #define WITH_YAML_CPP - #ifdef WITH_YAML_CPP doc = YamlCppParse(content); #else @@ -100,10 +104,6 @@ std::unique_ptr YamlConfigurationFactory::ParseString(std::string config = ConfigurationFactory::ParseConfiguration(root); } } - catch (const YAML::Exception &e) - { - OTEL_INTERNAL_LOG_ERROR("Failed to interpret yaml, " << e.what()); - } catch (...) { OTEL_INTERNAL_LOG_ERROR("Failed to interpret yaml."); diff --git a/sdk/src/init/sdk_builder.cc b/sdk/src/init/sdk_builder.cc index c7a7f95a53..7271d2e783 100644 --- a/sdk/src/init/sdk_builder.cc +++ b/sdk/src/init/sdk_builder.cc @@ -24,7 +24,6 @@ #include "opentelemetry/sdk/configuration/span_exporter_configuration_visitor.h" #include "opentelemetry/sdk/configuration/span_processor_configuration_visitor.h" #include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h" -#include "opentelemetry/sdk/configuration/yaml_document.h" #include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" #include "opentelemetry/sdk/init/configured_sdk.h" #include "opentelemetry/sdk/init/console_span_exporter_builder.h"