Support Programmatic Configuration without YAML dependencies
Background
The configuration spec requires programmatic configuration of the SDK in-memory that is independent of the file format (YAML, JSON, etc.).
See https://opentelemetry.io/docs/specs/otel/configuration/#programmatic
The SDK MUST provide a programmatic interface for all configuration. This interface SHOULD be written in the language of the SDK itself. All other configuration mechanisms SHOULD be built on top of this interface.
This interface exists in sdk/<include,src>/configuration and available through the opentelemetry_configuration CMake target. This target also includes the YAML parsing components
(ryml_document.cc, ryml_document_node.cc, yaml_configuration_parser.cc, and ryml dependency).
Currently there isn't a way to only use the programmatic configuration without bringing in the ryml dependency.
Proposal
Allow users to link to the programmatic configuration components independent from the YAML configuration components.
-
Split
opentelemetry_configurationinto two CMake targets:- ~~
opentelemetry_configuration~~opentelemetry_core: programmatic configuration components only.sdk_builder.cc,configured_sdk.cc,registry.cc, and component builders. - ~~
opentelemetry_configuration_yaml~~opentelemetry_configuration: yaml configuration components.yaml_configuration_parser.cc,ryml_document.cc,ryml_document_node.cc, and theryml::rymldependency.
- ~~
-
Build ~~
opentelemetry_configuration~~opentelemetry_configuration_core(programmatic configuration) unconditionally as part of the SDK. -
Repurpose the existing
WITH_CONFIGURATIONCMake option to gate only the YAML configuration target (opentelemetry_configuration_yaml) and therymldependency. -
Optional: Remove
doc_from theConfigurationclass and use a default constructor. CurrentlyConfigurationholds astd::unique_ptr<Document>to keep therymlparse tree alive for the duration ofConfigurationParser::Parse().
Example Programmatic Configuration
namespace cfg = opentelemetry::sdk::configuration;
auto model = std::make_unique<cfg::Configuration>();
auto tp = std::make_unique<cfg::TracerProviderConfiguration>();
auto otlp_grpc_exporter = std::make_unique<cfg::OtlpGrpcSpanExporterConfiguration>();
otlp_grpc_exporter->endpoint = "http://localhost:4317";
auto processor = std::make_unique<cfg::SimpleSpanProcessorConfiguration>();
processor->exporter = std::move(otlp_grpc_exporter);
tp->processors.push_back(std::move(processor));
model->tracer_provider = std::move(tp);
auto registry = std::make_shared<cfg::Registry>();
opentelemetry::exporter::otlp::OtlpGrpcSpanBuilder::Register(registry.get());
auto sdk = cfg::ConfiguredSdk::Create(registry, model);
sdk->Install();
Hi @marcalff @lalitb @dbarker @ThomsonTan ,
I've opened PR #4138 to resolve issue #4134 — splitting the opentelemetry_configuration CMake target into two separate targets so users can use programmatic configuration without pulling in the ryml dependency.
The EasyCLA check has passed. Could one of you please approve the workflow runs so CI can execute? Any feedback on the implementation is also very welcome.
Thank you!
Discussed in SIG meeting, this is a change we should implement. Removing the discuss flag.
Closing as completed by #4311