Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9846e83
add sdk logs component builders
dbarker Aug 5, 2026
f3328f3
add sdk metrics component builders
dbarker Aug 5, 2026
7977068
add sdk trace component builders
dbarker Aug 5, 2026
98345ed
update registry test
dbarker Aug 5, 2026
3c1ba5a
use sdk default builders in SdkBuilder
dbarker Aug 5, 2026
d077f5f
add registry factory
dbarker Aug 5, 2026
88bba8e
Update CMake and Bazel build files for sdk/configuration
dbarker Aug 5, 2026
a3442f3
update sdk configuration tests
dbarker Aug 5, 2026
d4c7101
update install tests to cover the new targets and headers
dbarker Aug 5, 2026
460eb32
update configuration yaml example and test it
dbarker Aug 5, 2026
10c5d51
fix clang-tidy and iwyu warnings
dbarker Aug 5, 2026
df70b99
clean up composite sampler yaml
dbarker Aug 5, 2026
bc9d335
add changelog entry
dbarker Aug 6, 2026
bf9fba3
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 6, 2026
6c4425a
[DO NOT REVIEW - this commit is to take the yaml file and example cha…
dbarker Aug 7, 2026
69b55ec
update the configuration example to use the registry factory
dbarker Aug 7, 2026
f34d649
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 7, 2026
3d02037
update sdk-default.yaml to highlight the registry methods used to rep…
dbarker Aug 7, 2026
5257fb1
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 7, 2026
53e9861
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 7, 2026
08d6f1f
fix hidden merge conflict on bazel file. clean up config example cmak…
dbarker Aug 7, 2026
a4ed885
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 7, 2026
1ded9c9
Create composite sampler builder interface. Create the default compos…
dbarker Aug 8, 2026
e217676
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 9, 2026
3b05f9d
cleanup the composite/composable sampler model by creating a composit…
dbarker Aug 9, 2026
8c26d52
Merge branch 'main' into config_create_sdk_signal_builders
dbarker Aug 11, 2026
ebe7b08
fix iwyu warning after merge
dbarker Aug 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ Increment the:

Breaking changes:

* [CONFIGURATION] SDK default component builder libraries and example
[#4367](https://github.com/open-telemetry/opentelemetry-cpp/pull/4367)
* The declaritive configuration registry is now empty on construction and
the default SDK component builders are provided optionally through
the `opentelemetry-cpp::configuration_registry_factory` library and
the `opentelemetry::sdk::configuration::RegistryFactory::Create()` method.

* [BUILD] Install an explicit list of ext headers instead of the whole
directory
[#4327](https://github.com/open-telemetry/opentelemetry-cpp/pull/4327)
Expand Down
33 changes: 33 additions & 0 deletions examples/configuration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cc_test(
"//exporters/prometheus:prometheus_exporter_builder",
"//sdk:headers",
"//sdk/src/configuration",
"//sdk/src/configuration:configuration_registry_factory",
"//sdk/src/logs",
"//sdk/src/metrics",
"//sdk/src/trace",
Expand Down Expand Up @@ -72,6 +73,38 @@ cc_test(
"//exporters/ostream:ostream_span_exporter_builder",
"//sdk:headers",
"//sdk/src/configuration",
"//sdk/src/configuration:configuration_registry_factory",
"//sdk/src/logs",
"//sdk/src/metrics",
"//sdk/src/trace",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "example_yaml_sdk_default",
size = "medium",
srcs = glob(["*.cc"]) + glob(["*.h"]),
args = [
"--test",
"--yaml",
"$(location sdk-default.yaml)",
],
data = ["sdk-default.yaml"],
tags = [
"test",
"yaml",
],
deps = [
"//api",
"//examples/common/logs_foo_library:common_logs_foo_library",
"//examples/common/metrics_foo_library:common_metrics_foo_library",
"//exporters/ostream:ostream_log_record_exporter_builder",
"//exporters/ostream:ostream_metric_exporter_builder",
"//exporters/ostream:ostream_span_exporter_builder",
"//sdk:headers",
"//sdk/src/configuration",
"//sdk/src/configuration:configuration_registry_factory",
"//sdk/src/logs",
"//sdk/src/metrics",
"//sdk/src/trace",
Expand Down
18 changes: 6 additions & 12 deletions examples/configuration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ add_executable(
target_link_libraries(
example_yaml
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
opentelemetry-cpp::configuration_registry_factory
opentelemetry-cpp::configuration
common_metrics_foo_library
common_logs_foo_library
opentelemetry-cpp::ostream_span_exporter_builder
Expand Down Expand Up @@ -61,18 +63,6 @@ if(WITH_PROMETHEUS)
PRIVATE opentelemetry-cpp::prometheus_exporter_builder)
endif()

if(DEFINED OPENTELEMETRY_BUILD_DLL)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The DLL build is not supported or tested for OTLP or Configuration classes (most are missing the required exports). Removing this to make the example easier to understand by moving the important config targets to the top of the file.

target_compile_definitions(example_yaml
PRIVATE OPENTELEMETRY_BUILD_IMPORT_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()

if(BUILD_TESTING)
if(WITH_OTLP_HTTP
AND WITH_OTLP_GRPC
Expand All @@ -86,4 +76,8 @@ if(BUILD_TESTING)
add_test(NAME examples.example_yaml_extensions
COMMAND $<TARGET_FILE:example_yaml> --test --yaml
${CMAKE_CURRENT_SOURCE_DIR}/extensions.yaml)

add_test(NAME examples.example_yaml_sdk_default
COMMAND $<TARGET_FILE:example_yaml> --test --yaml
${CMAKE_CURRENT_SOURCE_DIR}/sdk-default.yaml)
endif()
3 changes: 2 additions & 1 deletion examples/configuration/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "opentelemetry/sdk/configuration/configuration.h"
#include "opentelemetry/sdk/configuration/configured_sdk.h"
#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/configuration/registry_factory.h"
#include "opentelemetry/sdk/configuration/yaml_configuration_parser.h"

#include "custom_log_record_exporter_builder.h"
Expand Down Expand Up @@ -166,7 +167,7 @@ void InitOtel(const std::string &config_file)
/* 1 - Create a registry */

std::shared_ptr<opentelemetry::sdk::configuration::Registry> registry(
new opentelemetry::sdk::configuration::Registry);
opentelemetry::sdk::configuration::RegistryFactory::Create());

/* 2 - Populate the registry with the core components supported */

Expand Down
120 changes: 120 additions & 0 deletions examples/configuration/sdk-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Exercises the built-in SDK component builders.
#
# The Registry provides one builder per SDK component type. Each builder constructs its component from the parsed configuration model.
# RegistryFactory::Create() pre-loads all the SDK default builders shown in this file.
# Call Set*Builder() on the Registry to swap in your own implementation before calling ConfiguredSdk::Create:
#
# auto registry = RegistryFactory::Create();
# registry->SetBatchSpanProcessorBuilder(std::make_unique<MyBatchSpanProcessorBuilder>());
# auto sdk = ConfiguredSdk::Create(registry, model);

file_format: "1.1"
disabled: false

# --- Logs ---
logger_provider:
processors:
- batch: # Registry::SetBatchLogRecordProcessorBuilder
exporter:
console: # Registry::SetConsoleLogRecordBuilder
- simple: # Registry::SetSimpleLogRecordProcessorBuilder
exporter:
console: # Registry::SetConsoleLogRecordBuilder
logger_configurator/development: # Registry::SetLoggerConfiguratorBuilder
default_config:
enabled: true

# --- Metrics ---
meter_provider:
readers:
- periodic: # Registry::SetPeriodicMetricReaderBuilder
exporter:
console: # Registry::SetConsolePushMetricExporterBuilder
meter_configurator/development: # Registry::SetMeterConfiguratorBuilder
default_config:
enabled: true

# --- Propagators ---
propagator:
composite:
- tracecontext: # Registry::SetTextMapPropagatorBuilder("tracecontext")
- baggage: # Registry::SetTextMapPropagatorBuilder("baggage")
- b3: # Registry::SetTextMapPropagatorBuilder("b3")
- b3multi: # Registry::SetTextMapPropagatorBuilder("b3multi")
- jaeger: # Registry::SetTextMapPropagatorBuilder("jaeger")

# --- Traces ---
tracer_provider:
processors:
- batch: # Registry::SetBatchSpanProcessorBuilder
exporter:
console: # Registry::SetConsoleSpanBuilder
- simple: # Registry::SetSimpleSpanProcessorBuilder
exporter:
console: # Registry::SetConsoleSpanBuilder
sampler: # See kitchen-sink.yaml for sampler field semantics.
parent_based: # Registry::SetParentBasedSamplerBuilder
root:
composite/development:
rule_based: # Registry::SetComposableRuleBasedSamplerBuilder
rules:
- span_kinds:
- internal
sampler:
always_on: # Registry::SetComposableAlwaysOnSamplerBuilder
- attribute_patterns:
key: http.url
included:
- .*/health*
excluded:
- .*/healthz/live
sampler:
always_off: # Registry::SetComposableAlwaysOffSamplerBuilder
- attribute_values:
key: http.response.status_code
values:
- "500"
- "503"
sampler:
always_on: # Registry::SetComposableAlwaysOnSamplerBuilder
- span_kinds:
- server
- consumer
parent:
- none
sampler:
parent_threshold: # Registry::SetComposableParentThresholdSamplerBuilder
root:
probability: # Registry::SetComposableProbabilitySamplerBuilder
ratio: 0.25
- sampler:
probability: # Registry::SetComposableProbabilitySamplerBuilder
ratio: 0.01
remote_parent_sampled:
always_on: # Registry::SetAlwaysOnSamplerBuilder
remote_parent_not_sampled:
trace_id_ratio_based: # Registry::SetTraceIdRatioBasedSamplerBuilder
ratio: 0.001
local_parent_sampled:
always_off: # Registry::SetAlwaysOffSamplerBuilder
local_parent_not_sampled:
probability/development: # Registry::SetProbabilitySamplerBuilder
ratio: 0.001

tracer_configurator/development: # Registry::SetTracerConfiguratorBuilder
default_config:
enabled: false

resource:
attributes:
- name: service.name
value: sdk-builtin-test
detection/development:
detectors:
- container: # Registry::SetContainerResourceDetectorBuilder
- host: # Registry::SetHostResourceDetectorBuilder
- process: # Registry::SetProcessResourceDetectorBuilder
- service: # Registry::SetServiceResourceDetectorBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ include(GoogleTest)
add_executable(configuration_test ${INSTALL_TEST_SRC_DIR}/test_configuration.cc)
target_link_libraries(
configuration_test
PRIVATE opentelemetry-cpp::configuration
PRIVATE opentelemetry-cpp::configuration_registry_factory
opentelemetry-cpp::configuration
opentelemetry-cpp::ostream_log_record_exporter_builder
opentelemetry-cpp::ostream_metrics_exporter_builder
opentelemetry-cpp::ostream_span_exporter_builder
Expand Down
4 changes: 4 additions & 0 deletions install/test/cmake/component_tests/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ target_link_libraries(
opentelemetry-cpp::metrics
opentelemetry-cpp::logs
opentelemetry-cpp::configuration_core
opentelemetry-cpp::configuration_trace_builders
opentelemetry-cpp::configuration_metrics_builders
opentelemetry-cpp::configuration_logs_builders
opentelemetry-cpp::configuration_registry_factory
GTest::gtest
GTest::gtest_main)

Expand Down
4 changes: 4 additions & 0 deletions install/test/cmake/fetch_content_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ target_link_libraries(
opentelemetry-cpp::trace
opentelemetry-cpp::logs
opentelemetry-cpp::configuration_core
opentelemetry-cpp::configuration_trace_builders
opentelemetry-cpp::configuration_metrics_builders
opentelemetry-cpp::configuration_logs_builders
opentelemetry-cpp::configuration_registry_factory
opentelemetry-cpp::configuration
opentelemetry-cpp::resource_detectors
opentelemetry-cpp::http_client
Expand Down
5 changes: 3 additions & 2 deletions install/test/src/test_configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
#include "opentelemetry/sdk/configuration/configuration.h"
#include "opentelemetry/sdk/configuration/configured_sdk.h"
#include "opentelemetry/sdk/configuration/registry.h"
#include "opentelemetry/sdk/configuration/registry_factory.h"
#include "opentelemetry/sdk/configuration/yaml_configuration_parser.h"

TEST(ConfigurationInstallTest, ConfigurationCheck)
{
std::shared_ptr<opentelemetry::sdk::configuration::Registry> registry(
new opentelemetry::sdk::configuration::Registry);
std::shared_ptr<opentelemetry::sdk::configuration::Registry> registry =
opentelemetry::sdk::configuration::RegistryFactory::Create();
EXPECT_NE(registry, nullptr);

opentelemetry::exporter::trace::ConsoleSpanBuilder::Register(registry.get());
Expand Down
Loading
Loading