Skip to content
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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)
option(WITH_CONFIGURATION
"EXPERIMENTAL: YAML configuration file support (ryml dependency)" OFF)

#
# We do not want to have WITH_ABI_VERSION = "1" or "2", and instead prefer two
Expand Down
1 change: 1 addition & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ elif [[ "$1" == "cmake.install.test" ]]; then
"api"
"sdk"
"configuration"
"configuration_yaml"
"ext_common"
"ext_http"
"ext_http_curl"
Expand Down
2 changes: 1 addition & 1 deletion examples/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if(DEFINED OPENTELEMETRY_BUILD_DLL)
else()
target_link_libraries(
example_yaml
PRIVATE opentelemetry-cpp::configuration opentelemetry-cpp::common
PRIVATE opentelemetry-cpp::configuration_yaml opentelemetry-cpp::common
opentelemetry-cpp::trace opentelemetry-cpp::logs)
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 3.16)
project(opentelemetry-cpp-configuration-install-test LANGUAGES CXX)

find_package(opentelemetry-cpp REQUIRED COMPONENTS configuration
Comment thread
dbarker marked this conversation as resolved.
find_package(opentelemetry-cpp REQUIRED COMPONENTS configuration_yaml
exporters_ostream_builder)

if(NOT TARGET Threads::Threads)
Expand All @@ -17,7 +17,7 @@ include(GoogleTest)
add_executable(configuration_test ${INSTALL_TEST_SRC_DIR}/test_configuration.cc)
target_link_libraries(
configuration_test
PRIVATE opentelemetry-cpp::configuration
Comment thread
dbarker marked this conversation as resolved.
Comment thread
dbarker marked this conversation as resolved.
PRIVATE opentelemetry-cpp::configuration_yaml
opentelemetry-cpp::ostream_log_record_exporter_builder
opentelemetry-cpp::ostream_metrics_exporter_builder
opentelemetry-cpp::ostream_span_exporter_builder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.16)
project(opentelemetry-cpp-configuration-yaml-install-test LANGUAGES CXX)

find_package(opentelemetry-cpp REQUIRED COMPONENTS configuration_yaml)

if(NOT TARGET Threads::Threads)
message(FATAL_ERROR "Threads::Threads target not found")
endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a check that the ryml target has been imported.


find_package(GTest CONFIG REQUIRED)
include(GoogleTest)

add_executable(configuration_yaml_test
${INSTALL_TEST_SRC_DIR}/test_configuration_yaml.cc)
target_link_libraries(
configuration_yaml_test PRIVATE opentelemetry-cpp::configuration_yaml
GTest::gtest GTest::gtest_main)

gtest_discover_tests(configuration_yaml_test)
2 changes: 1 addition & 1 deletion install/test/cmake/examples_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ if("ext_http_curl" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED)
set(WITH_HTTP_CLIENT_CURL ON)
endif()

if("configuration" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED)
if("configuration_yaml" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED)
set(WITH_CONFIGURATION ON)
endif()

Expand Down
25 changes: 25 additions & 0 deletions install/test/src/test_configuration_yaml.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <gtest/gtest.h>

#include "opentelemetry/sdk/configuration/configuration.h"
#include "opentelemetry/sdk/configuration/yaml_configuration_parser.h"

TEST(ConfigurationYamlInstallTest, ParseYamlString)
{
static const std::string source("test");

std::string yaml = R"(
file_format: "1.0"
logger_provider:
processors:
- simple:
exporter:
console:
)";

auto model =
opentelemetry::sdk::configuration::YamlConfigurationParser::ParseString(source, yaml);
EXPECT_NE(model, nullptr);
}
27 changes: 24 additions & 3 deletions sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,40 @@ otel_add_component(
"sdk/configuration/*.h"
EXCLUDE)

otel_add_component(
COMPONENT
configuration
TARGETS
opentelemetry_configuration
FILES_DIRECTORY
"include/opentelemetry/"
FILES_DESTINATION
"include/opentelemetry"
FILES_MATCHING
PATTERN
"sdk/configuration/*.h"
PATTERN
"sdk/configuration/ryml_*.h"
EXCLUDE
PATTERN
"sdk/configuration/yaml_configuration_parser.h"
EXCLUDE)

if(WITH_CONFIGURATION)
otel_add_component(
COMPONENT
configuration
configuration_yaml
TARGETS
opentelemetry_configuration
opentelemetry_configuration_yaml
FILES_DIRECTORY
"include/opentelemetry/"
FILES_DESTINATION
"include/opentelemetry"
FILES_MATCHING
PATTERN
"sdk/configuration/*.h")
"sdk/configuration/ryml_*.h"
PATTERN
"sdk/configuration/yaml_configuration_parser.h")
endif()

if(BUILD_TESTING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace configuration
class Configuration
{
public:
Configuration() = default;
Configuration(std::unique_ptr<Document> doc) : doc_(std::move(doc)) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is coupling the Configuration class with the parsed document still required?

Configuration(Configuration &&) = delete;
Configuration(const Configuration &) = delete;
Expand Down
4 changes: 1 addition & 3 deletions sdk/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ add_subdirectory(logs)
add_subdirectory(version)
add_subdirectory(resource)

if(WITH_CONFIGURATION)
add_subdirectory(configuration)
endif()
add_subdirectory(configuration)
35 changes: 29 additions & 6 deletions sdk/src/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ 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
Expand All @@ -29,12 +26,38 @@ target_include_directories(
target_link_libraries(
opentelemetry_configuration
PUBLIC opentelemetry_api opentelemetry_common opentelemetry_trace
opentelemetry_metrics opentelemetry_logs
PRIVATE ryml::ryml)
opentelemetry_metrics opentelemetry_logs)

if(OPENTELEMETRY_INSTALL)
opentelemetry_add_pkgconfig(
configuration "OpenTelemetry SDK - Configuration"
"Components for exporting traces in the OpenTelemetry SDK."
"Programmatic configuration components for the OpenTelemetry SDK."
"opentelemetry_configuration")
endif()

if(WITH_CONFIGURATION)
add_library(
opentelemetry_configuration_yaml yaml_configuration_parser.cc
ryml_document.cc ryml_document_node.cc)

set_target_properties(opentelemetry_configuration_yaml
PROPERTIES EXPORT_NAME configuration_yaml)
set_target_version(opentelemetry_configuration_yaml)

target_include_directories(
opentelemetry_configuration_yaml
PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/sdk/include>"
"$<INSTALL_INTERFACE:include>")

target_link_libraries(
opentelemetry_configuration_yaml
PUBLIC opentelemetry_configuration
PRIVATE ryml::ryml)

if(OPENTELEMETRY_INSTALL)
opentelemetry_add_pkgconfig(
configuration_yaml "OpenTelemetry SDK - YAML Configuration"
"YAML file configuration components for the OpenTelemetry SDK."
"opentelemetry_configuration_yaml")
endif()
endif()
1 change: 1 addition & 0 deletions sdk/src/configuration/registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>

#include "opentelemetry/baggage/propagation/baggage_propagator.h"
#include "opentelemetry/context/propagation/text_map_propagator.h"
#include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h"
#include "opentelemetry/sdk/configuration/extension_log_record_processor_builder.h"
#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_builder.h"
Expand Down
9 changes: 4 additions & 5 deletions sdk/src/configuration/sdk_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h"
#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h"
#include "opentelemetry/sdk/configuration/exemplar_filter.h"
#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h"
#include "opentelemetry/sdk/configuration/extension_log_record_exporter_builder.h"
#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h"
Expand Down Expand Up @@ -139,7 +140,9 @@
#include "opentelemetry/sdk/logs/processor.h"
#include "opentelemetry/sdk/logs/simple_log_record_processor_factory.h"
#include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h"
#include "opentelemetry/sdk/metrics/exemplar/filter_type.h"
#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW
# include "opentelemetry/sdk/metrics/exemplar/filter_type.h"
#endif
#include "opentelemetry/sdk/metrics/export/metric_producer.h"
#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_factory.h"
#include "opentelemetry/sdk/metrics/export/periodic_exporting_metric_reader_options.h"
Expand Down Expand Up @@ -176,10 +179,6 @@
#include "opentelemetry/version.h"
#include "src/common/wildcard_match.h"

#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW
# include "opentelemetry/sdk/configuration/exemplar_filter.h"
#endif

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
Expand Down
5 changes: 3 additions & 2 deletions sdk/test/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ foreach(
yaml_trace_test
yaml_distribution_test)
add_executable(${testname} "${testname}.cc")
target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} opentelemetry_configuration)
target_link_libraries(
${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
opentelemetry_configuration_yaml)
gtest_add_tests(
TARGET ${testname}
TEST_PREFIX trace.
Expand Down
Loading