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_configuration into two CMake targets:
opentelemetry_configuration: programmatic configuration components only. sdk_builder.cc,
configured_sdk.cc, registry.cc, and component builders.
opentelemetry_configuration_yaml: yaml configuration components. yaml_configuration_parser.cc,
ryml_document.cc, ryml_document_node.cc, and the ryml::ryml
dependency.
-
Build opentelemetry_configuration (programmatic configuration) unconditionally as part of the SDK.
-
Repurpose the existing WITH_CONFIGURATION CMake option to gate only the
YAML configuration target (opentelemetry_configuration_yaml) and the ryml dependency.
-
Optional: Remove doc_ from the Configuration class and use a default constructor. Currently Configuration holds a std::unique_ptr<Document> to keep the ryml parse tree alive
for the duration of ConfigurationParser::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();
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
This interface exists in
sdk/<include,src>/configurationand available through theopentelemetry_configurationCMake target. This target also includes the YAML parsing components(
ryml_document.cc,ryml_document_node.cc,yaml_configuration_parser.cc, andrymldependency).Currently there isn't a way to only use the programmatic configuration without bringing in the
rymldependency.Proposal
Allow users to link to the programmatic configuration components independent from the YAML configuration components.
Split
opentelemetry_configurationinto two CMake targets:opentelemetry_configuration: programmatic configuration components only.sdk_builder.cc,configured_sdk.cc,registry.cc, and component builders.opentelemetry_configuration_yaml: yaml configuration components.yaml_configuration_parser.cc,ryml_document.cc,ryml_document_node.cc, and theryml::rymldependency.
Build
opentelemetry_configuration(programmatic configuration) unconditionally as part of the SDK.Repurpose the existing
WITH_CONFIGURATIONCMake option to gate only theYAML 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 alivefor the duration of
ConfigurationParser::Parse().Example Programmatic Configuration