From a1396902855af4e77624d4439fce047863bc195f Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 7 Sep 2025 23:26:02 +0200 Subject: [PATCH 1/4] [CONFIGURATION] File configuration - semantic version --- .../shelltests/kitchen-sink.test | 2 +- .../shelltests/kitchen-sink.yaml | 2 +- .../sdk/configuration/configuration_parser.h | 332 +++++++++++++++++- .../integer_attribute_value_configuration.h | 4 +- sdk/src/configuration/configuration_parser.cc | 324 ++++++++++------- sdk/src/configuration/sdk_builder.cc | 4 +- .../yaml_configuration_parser.cc | 3 +- sdk/test/configuration/yaml_logs_test.cc | 32 +- sdk/test/configuration/yaml_metrics_test.cc | 54 +-- .../configuration/yaml_propagator_test.cc | 18 +- sdk/test/configuration/yaml_resource_test.cc | 26 +- sdk/test/configuration/yaml_test.cc | 163 ++++++--- sdk/test/configuration/yaml_trace_test.cc | 56 +-- tbump.toml | 4 + 14 files changed, 744 insertions(+), 280 deletions(-) diff --git a/functional/configuration/shelltests/kitchen-sink.test b/functional/configuration/shelltests/kitchen-sink.test index 24d58a03c5..3da0094158 100644 --- a/functional/configuration/shelltests/kitchen-sink.test +++ b/functional/configuration/shelltests/kitchen-sink.test @@ -19,7 +19,7 @@ SDK CREATED severity_text : DEBUG body : body resource : - telemetry.sdk.version: 1.22.0 + telemetry.sdk.version: 1.23.0-dev service.version: 1.0.0 double_array_key: [1.1,2.2] double_key: 1.1 diff --git a/functional/configuration/shelltests/kitchen-sink.yaml b/functional/configuration/shelltests/kitchen-sink.yaml index de8d00be68..154f1a8d5a 100644 --- a/functional/configuration/shelltests/kitchen-sink.yaml +++ b/functional/configuration/shelltests/kitchen-sink.yaml @@ -11,7 +11,7 @@ # The file format version. # The yaml format is documented at # https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema -file_format: "1.0-rc.1" +file_format: "1.0.0-rc.1" # Configure if the SDK is disabled or not. # If omitted or null, false is used. disabled: false diff --git a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h index cd4f6e3af5..392a4b0798 100644 --- a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h +++ b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h @@ -5,8 +5,89 @@ #include +#include "opentelemetry/sdk/configuration/aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/always_off_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/always_on_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/attribute_limits_configuration.h" +#include "opentelemetry/sdk/configuration/attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/attributes_configuration.h" +#include "opentelemetry/sdk/configuration/base2_exponential_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/batch_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/boolean_attribute_value_configuration.h" #include "opentelemetry/sdk/configuration/configuration.h" +#include "opentelemetry/sdk/configuration/configuration_parser.h" +#include "opentelemetry/sdk/configuration/console_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/console_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/console_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/default_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/default_histogram_aggregation.h" +#include "opentelemetry/sdk/configuration/document.h" #include "opentelemetry/sdk/configuration/document_node.h" +#include "opentelemetry/sdk/configuration/double_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/double_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/drop_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/explicit_bucket_histogram_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/extension_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/extension_metric_producer_configuration.h" +#include "opentelemetry/sdk/configuration/extension_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/extension_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/headers_configuration.h" +#include "opentelemetry/sdk/configuration/include_exclude_configuration.h" +#include "opentelemetry/sdk/configuration/instrument_type.h" +#include "opentelemetry/sdk/configuration/integer_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/integer_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/invalid_schema_exception.h" +#include "opentelemetry/sdk/configuration/jaeger_remote_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/last_value_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_limits_configuration.h" +#include "opentelemetry/sdk/configuration/log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/logger_provider_configuration.h" +#include "opentelemetry/sdk/configuration/meter_provider_configuration.h" +#include "opentelemetry/sdk/configuration/metric_producer_configuration.h" +#include "opentelemetry/sdk/configuration/metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/open_census_metric_producer_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_file_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_encoding.h" +#include "opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/parent_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/prometheus_pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/propagator_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/pull_metric_reader_configuration.h" +#include "opentelemetry/sdk/configuration/push_metric_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/resource_configuration.h" +#include "opentelemetry/sdk/configuration/sampler_configuration.h" +#include "opentelemetry/sdk/configuration/simple_log_record_processor_configuration.h" +#include "opentelemetry/sdk/configuration/simple_span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/span_exporter_configuration.h" +#include "opentelemetry/sdk/configuration/span_limits_configuration.h" +#include "opentelemetry/sdk/configuration/span_processor_configuration.h" +#include "opentelemetry/sdk/configuration/string_array_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/string_array_configuration.h" +#include "opentelemetry/sdk/configuration/string_attribute_value_configuration.h" +#include "opentelemetry/sdk/configuration/sum_aggregation_configuration.h" +#include "opentelemetry/sdk/configuration/temporality_preference.h" +#include "opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" +#include "opentelemetry/sdk/configuration/view_configuration.h" +#include "opentelemetry/sdk/configuration/view_selector_configuration.h" +#include "opentelemetry/sdk/configuration/view_stream_configuration.h" +#include "opentelemetry/sdk/configuration/zipkin_span_exporter_configuration.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -18,7 +99,256 @@ namespace configuration class ConfigurationParser { public: - static std::unique_ptr Parse(std::unique_ptr doc); + OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name); + + std::unique_ptr ParseStringArrayConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseIncludeExcludeConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseHeadersConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseAttributeLimitsConfiguration( + const std::unique_ptr &node); + + std::unique_ptr + ParseOtlpHttpLogRecordExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseOtlpGrpcLogRecordExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseOtlpFileLogRecordExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr ParseConsoleLogRecordExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr + ParseExtensionLogRecordExporterConfiguration(const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParseLogRecordExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseBatchLogRecordProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseSimpleLogRecordProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr + ParseExtensionLogRecordProcessorConfiguration(const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParseLogRecordProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseLogRecordLimitsConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseLoggerProviderConfiguration( + const std::unique_ptr &node); + + DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name); + + TemporalityPreference ParseTemporalityPreference(const std::string &name); + + std::unique_ptr + ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseOtlpGrpcPushMetricExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseOtlpFilePushMetricExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseConsolePushMetricExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParsePrometheusPullMetricExporterConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParsePushMetricExporterExtensionConfiguration(const std::string &name, + std::unique_ptr node); + + std::unique_ptr + ParsePullMetricExporterExtensionConfiguration(const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParsePushMetricExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParsePullMetricExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseOpenCensusMetricProducerConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseExtensionMetricProducerConfiguration( + const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParseMetricProducerConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParsePeriodicMetricReaderConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParsePullMetricReaderConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseMetricReaderConfiguration( + const std::unique_ptr &node); + + InstrumentType ParseInstrumentType(const std::string &name); + + std::unique_ptr ParseViewSelectorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseDefaultAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseDropAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr + ParseExplicitBucketHistogramAggregationConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseBase2ExponentialBucketHistogramAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseLastValueAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseSumAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseAggregationConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseViewStreamConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseViewConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseMeterProviderConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParsePropagatorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseSpanLimitsConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseAlwaysOffSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseAlwaysOnSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseJaegerRemoteSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseParentBasedSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseTraceIdRatioBasedSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseSamplerExtensionConfiguration( + const std::string &name, + std::unique_ptr node, + size_t depth); + + std::unique_ptr ParseSamplerConfiguration( + const std::unique_ptr &node, + size_t depth); + + std::unique_ptr ParseOtlpHttpSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseOtlpGrpcSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseOtlpFileSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseConsoleSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseZipkinSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseExtensionSpanExporterConfiguration( + const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParseSpanExporterConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseBatchSpanProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseSimpleSpanProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseExtensionSpanProcessorConfiguration( + const std::string &name, + std::unique_ptr node); + + std::unique_ptr ParseSpanProcessorConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseTracerProviderConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseStringAttributeValueConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseIntegerAttributeValueConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseDoubleAttributeValueConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseBooleanAttributeValueConfiguration( + const std::unique_ptr &node); + + std::unique_ptr + ParseStringArrayAttributeValueConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseIntegerArrayAttributeValueConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseDoubleArrayAttributeValueConfiguration(const std::unique_ptr &node); + + std::unique_ptr + ParseBooleanArrayAttributeValueConfiguration(const std::unique_ptr &node); + + std::unique_ptr ParseAttributesConfiguration( + const std::unique_ptr &node); + + std::unique_ptr ParseResourceConfiguration( + const std::unique_ptr &node); + + std::unique_ptr Parse(std::unique_ptr doc); + +private: + std::string version_; + int version_major_; + int version_minor_; + int version_patch_; }; } // namespace configuration diff --git a/sdk/include/opentelemetry/sdk/configuration/integer_attribute_value_configuration.h b/sdk/include/opentelemetry/sdk/configuration/integer_attribute_value_configuration.h index 4fa558157d..0b72fd7afc 100644 --- a/sdk/include/opentelemetry/sdk/configuration/integer_attribute_value_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/integer_attribute_value_configuration.h @@ -3,8 +3,6 @@ #pragma once -#include - #include "opentelemetry/sdk/configuration/attribute_value_configuration.h" #include "opentelemetry/sdk/configuration/attribute_value_configuration_visitor.h" #include "opentelemetry/version.h" @@ -25,7 +23,7 @@ class IntegerAttributeValueConfiguration : public AttributeValueConfiguration visitor->VisitInteger(this); } - std::size_t value; + long long value; }; } // namespace configuration diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index 7b0abcbca7..da26865aec 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -105,7 +105,7 @@ namespace configuration // FIXME: proper sizing constexpr size_t MAX_SAMPLER_DEPTH = 10; -static OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name) +OtlpHttpEncoding ConfigurationParser::ParseOtlpHttpEncoding(const std::string &name) { if (name == "protobuf") { @@ -122,7 +122,7 @@ static OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name) throw InvalidSchemaException(message); } -static std::unique_ptr ParseStringArrayConfiguration( +std::unique_ptr ConfigurationParser::ParseStringArrayConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -139,7 +139,7 @@ static std::unique_ptr ParseStringArrayConfiguration( return model; } -static std::unique_ptr ParseIncludeExcludeConfiguration( +std::unique_ptr ConfigurationParser::ParseIncludeExcludeConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -160,7 +160,7 @@ static std::unique_ptr ParseIncludeExcludeConfigura return model; } -static std::unique_ptr ParseHeadersConfiguration( +std::unique_ptr ConfigurationParser::ParseHeadersConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -188,8 +188,8 @@ static std::unique_ptr ParseHeadersConfiguration( return model; } -static std::unique_ptr ParseAttributeLimitsConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseAttributeLimitsConfiguration(const std::unique_ptr &node) { auto model = std::make_unique(); @@ -199,8 +199,9 @@ static std::unique_ptr ParseAttributeLimitsConfigu return model; } -static std::unique_ptr -ParseOtlpHttpLogRecordExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpHttpLogRecordExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -226,8 +227,9 @@ ParseOtlpHttpLogRecordExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseOtlpGrpcLogRecordExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpGrpcLogRecordExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -251,8 +253,9 @@ ParseOtlpGrpcLogRecordExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseOtlpFileLogRecordExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpFileLogRecordExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -262,17 +265,19 @@ ParseOtlpFileLogRecordExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseConsoleLogRecordExporterConfiguration(const std::unique_ptr & /* node */) +std::unique_ptr +ConfigurationParser::ParseConsoleLogRecordExporterConfiguration( + const std::unique_ptr & /* node */) { auto model = std::make_unique(); return model; } -static std::unique_ptr -ParseExtensionLogRecordExporterConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParseExtensionLogRecordExporterConfiguration( + const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -282,8 +287,8 @@ ParseExtensionLogRecordExporterConfiguration(const std::string &name, return model; } -static std::unique_ptr ParseLogRecordExporterConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseLogRecordExporterConfiguration(const std::unique_ptr &node) { std::unique_ptr model; @@ -329,8 +334,9 @@ static std::unique_ptr ParseLogRecordExporterCon return model; } -static std::unique_ptr -ParseBatchLogRecordProcessorConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseBatchLogRecordProcessorConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -346,8 +352,9 @@ ParseBatchLogRecordProcessorConfiguration(const std::unique_ptr &n return model; } -static std::unique_ptr -ParseSimpleLogRecordProcessorConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseSimpleLogRecordProcessorConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -358,9 +365,10 @@ ParseSimpleLogRecordProcessorConfiguration(const std::unique_ptr & return model; } -static std::unique_ptr -ParseExtensionLogRecordProcessorConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParseExtensionLogRecordProcessorConfiguration( + const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -370,8 +378,8 @@ ParseExtensionLogRecordProcessorConfiguration(const std::string &name, return model; } -static std::unique_ptr ParseLogRecordProcessorConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseLogRecordProcessorConfiguration(const std::unique_ptr &node) { std::unique_ptr model; @@ -409,8 +417,8 @@ static std::unique_ptr ParseLogRecordProcessorC return model; } -static std::unique_ptr ParseLogRecordLimitsConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseLogRecordLimitsConfiguration(const std::unique_ptr &node) { auto model = std::make_unique(); @@ -420,7 +428,7 @@ static std::unique_ptr ParseLogRecordLimitsConfigu return model; } -static std::unique_ptr ParseLoggerProviderConfiguration( +std::unique_ptr ConfigurationParser::ParseLoggerProviderConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -449,7 +457,8 @@ static std::unique_ptr ParseLoggerProviderConfigura return model; } -static DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name) +DefaultHistogramAggregation ConfigurationParser::ParseDefaultHistogramAggregation( + const std::string &name) { if (name == "explicit_bucket_histogram") { @@ -466,7 +475,7 @@ static DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::s throw InvalidSchemaException(message); } -static TemporalityPreference ParseTemporalityPreference(const std::string &name) +TemporalityPreference ConfigurationParser::ParseTemporalityPreference(const std::string &name) { if (name == "cumulative") { @@ -488,8 +497,9 @@ static TemporalityPreference ParseTemporalityPreference(const std::string &name) throw InvalidSchemaException(message); } -static std::unique_ptr -ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpHttpPushMetricExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -523,8 +533,9 @@ ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseOtlpGrpcPushMetricExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpGrpcPushMetricExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -557,8 +568,9 @@ ParseOtlpGrpcPushMetricExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseOtlpFilePushMetricExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseOtlpFilePushMetricExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -576,8 +588,9 @@ ParseOtlpFilePushMetricExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseConsolePushMetricExporterConfiguration(const std::unique_ptr & /* node */) +std::unique_ptr +ConfigurationParser::ParseConsolePushMetricExporterConfiguration( + const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -586,8 +599,9 @@ ParseConsolePushMetricExporterConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParsePrometheusPullMetricExporterConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); @@ -600,9 +614,10 @@ ParsePrometheusPullMetricExporterConfiguration(const std::unique_ptr -ParsePushMetricExporterExtensionConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParsePushMetricExporterExtensionConfiguration( + const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -612,9 +627,10 @@ ParsePushMetricExporterExtensionConfiguration(const std::string &name, return model; } -static std::unique_ptr -ParsePullMetricExporterExtensionConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParsePullMetricExporterExtensionConfiguration( + const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -624,8 +640,8 @@ ParsePullMetricExporterExtensionConfiguration(const std::string &name, return model; } -static std::unique_ptr ParsePushMetricExporterConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParsePushMetricExporterConfiguration(const std::unique_ptr &node) { std::unique_ptr model; @@ -671,8 +687,8 @@ static std::unique_ptr ParsePushMetricExporterC return model; } -static std::unique_ptr ParsePullMetricExporterConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParsePullMetricExporterConfiguration(const std::unique_ptr &node) { std::unique_ptr model; @@ -706,17 +722,18 @@ static std::unique_ptr ParsePullMetricExporterC return model; } -static std::unique_ptr -ParseOpenCensusMetricProducerConfiguration(const std::unique_ptr & /* node */) +std::unique_ptr +ConfigurationParser::ParseOpenCensusMetricProducerConfiguration( + const std::unique_ptr & /* node */) { auto model = std::make_unique(); return model; } -static std::unique_ptr -ParseExtensionMetricProducerConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParseExtensionMetricProducerConfiguration(const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -726,7 +743,7 @@ ParseExtensionMetricProducerConfiguration(const std::string &name, return model; } -static std::unique_ptr ParseMetricProducerConfiguration( +std::unique_ptr ConfigurationParser::ParseMetricProducerConfiguration( const std::unique_ptr &node) { std::unique_ptr model; @@ -761,7 +778,8 @@ static std::unique_ptr ParseMetricProducerConfigura return model; } -static std::unique_ptr ParsePeriodicMetricReaderConfiguration( +std::unique_ptr +ConfigurationParser::ParsePeriodicMetricReaderConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -786,8 +804,8 @@ static std::unique_ptr ParsePeriodicMetricRea return model; } -static std::unique_ptr ParsePullMetricReaderConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParsePullMetricReaderConfiguration(const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -808,7 +826,7 @@ static std::unique_ptr ParsePullMetricReaderConfi return model; } -static std::unique_ptr ParseMetricReaderConfiguration( +std::unique_ptr ConfigurationParser::ParseMetricReaderConfiguration( const std::unique_ptr &node) { std::unique_ptr model; @@ -849,7 +867,7 @@ static std::unique_ptr ParseMetricReaderConfiguration return model; } -static InstrumentType ParseInstrumentType(const std::string &name) +InstrumentType ConfigurationParser::ParseInstrumentType(const std::string &name) { if (name == "") { @@ -891,7 +909,7 @@ static InstrumentType ParseInstrumentType(const std::string &name) throw InvalidSchemaException(message); } -static std::unique_ptr ParseViewSelectorConfiguration( +std::unique_ptr ConfigurationParser::ParseViewSelectorConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -909,7 +927,8 @@ static std::unique_ptr ParseViewSelectorConfiguration return model; } -static std::unique_ptr ParseDefaultAggregationConfiguration( +std::unique_ptr +ConfigurationParser::ParseDefaultAggregationConfiguration( const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -917,7 +936,8 @@ static std::unique_ptr ParseDefaultAggregationC return model; } -static std::unique_ptr ParseDropAggregationConfiguration( +std::unique_ptr +ConfigurationParser::ParseDropAggregationConfiguration( const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -925,8 +945,9 @@ static std::unique_ptr ParseDropAggregationConfigu return model; } -static std::unique_ptr -ParseExplicitBucketHistogramAggregationConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseExplicitBucketHistogramAggregationConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -950,8 +971,8 @@ ParseExplicitBucketHistogramAggregationConfiguration(const std::unique_ptr -ParseBase2ExponentialBucketHistogramAggregationConfiguration( +std::unique_ptr +ConfigurationParser::ParseBase2ExponentialBucketHistogramAggregationConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -963,7 +984,8 @@ ParseBase2ExponentialBucketHistogramAggregationConfiguration( return model; } -static std::unique_ptr ParseLastValueAggregationConfiguration( +std::unique_ptr +ConfigurationParser::ParseLastValueAggregationConfiguration( const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -971,7 +993,7 @@ static std::unique_ptr ParseLastValueAggregat return model; } -static std::unique_ptr ParseSumAggregationConfiguration( +std::unique_ptr ConfigurationParser::ParseSumAggregationConfiguration( const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -979,7 +1001,7 @@ static std::unique_ptr ParseSumAggregationConfigura return model; } -static std::unique_ptr ParseAggregationConfiguration( +std::unique_ptr ConfigurationParser::ParseAggregationConfiguration( const std::unique_ptr &node) { std::unique_ptr model; @@ -1031,7 +1053,7 @@ static std::unique_ptr ParseAggregationConfiguration( return model; } -static std::unique_ptr ParseViewStreamConfiguration( +std::unique_ptr ConfigurationParser::ParseViewStreamConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1056,7 +1078,7 @@ static std::unique_ptr ParseViewStreamConfiguration( return model; } -static std::unique_ptr ParseViewConfiguration( +std::unique_ptr ConfigurationParser::ParseViewConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1071,7 +1093,7 @@ static std::unique_ptr ParseViewConfiguration( return model; } -static std::unique_ptr ParseMeterProviderConfiguration( +std::unique_ptr ConfigurationParser::ParseMeterProviderConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1103,7 +1125,7 @@ static std::unique_ptr ParseMeterProviderConfigurati return model; } -static std::unique_ptr ParsePropagatorConfiguration( +std::unique_ptr ConfigurationParser::ParsePropagatorConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1147,7 +1169,7 @@ static std::unique_ptr ParsePropagatorConfiguration( return model; } -static std::unique_ptr ParseSpanLimitsConfiguration( +std::unique_ptr ConfigurationParser::ParseSpanLimitsConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1162,11 +1184,8 @@ static std::unique_ptr ParseSpanLimitsConfiguration( return model; } -static std::unique_ptr ParseSamplerConfiguration( - const std::unique_ptr &node, - size_t depth); - -static std::unique_ptr ParseAlwaysOffSamplerConfiguration( +std::unique_ptr +ConfigurationParser::ParseAlwaysOffSamplerConfiguration( const std::unique_ptr & /* node */, size_t /* depth */) { @@ -1175,7 +1194,8 @@ static std::unique_ptr ParseAlwaysOffSamplerConfi return model; } -static std::unique_ptr ParseAlwaysOnSamplerConfiguration( +std::unique_ptr +ConfigurationParser::ParseAlwaysOnSamplerConfiguration( const std::unique_ptr & /* node */, size_t /* depth */) { @@ -1185,7 +1205,8 @@ static std::unique_ptr ParseAlwaysOnSamplerConfigu } // NOLINTBEGIN(misc-no-recursion) -static std::unique_ptr ParseJaegerRemoteSamplerConfiguration( +std::unique_ptr +ConfigurationParser::ParseJaegerRemoteSamplerConfiguration( const std::unique_ptr &node, size_t depth) { @@ -1210,9 +1231,9 @@ static std::unique_ptr ParseJaegerRemoteSample // NOLINTEND(misc-no-recursion) // NOLINTBEGIN(misc-no-recursion) -static std::unique_ptr ParseParentBasedSamplerConfiguration( - const std::unique_ptr &node, - size_t depth) +std::unique_ptr +ConfigurationParser::ParseParentBasedSamplerConfiguration(const std::unique_ptr &node, + size_t depth) { auto model = std::make_unique(); std::unique_ptr child; @@ -1251,9 +1272,10 @@ static std::unique_ptr ParseParentBasedSamplerC } // NOLINTEND(misc-no-recursion) -static std::unique_ptr -ParseTraceIdRatioBasedSamplerConfiguration(const std::unique_ptr &node, - size_t /* depth */) +std::unique_ptr +ConfigurationParser::ParseTraceIdRatioBasedSamplerConfiguration( + const std::unique_ptr &node, + size_t /* depth */) { auto model = std::make_unique(); std::unique_ptr child; @@ -1263,10 +1285,10 @@ ParseTraceIdRatioBasedSamplerConfiguration(const std::unique_ptr & return model; } -static std::unique_ptr ParseSamplerExtensionConfiguration( - const std::string &name, - std::unique_ptr node, - size_t depth) +std::unique_ptr +ConfigurationParser::ParseSamplerExtensionConfiguration(const std::string &name, + std::unique_ptr node, + size_t depth) { auto model = std::make_unique(); @@ -1278,7 +1300,7 @@ static std::unique_ptr ParseSamplerExtensionConfi } // NOLINTBEGIN(misc-no-recursion) -static std::unique_ptr ParseSamplerConfiguration( +std::unique_ptr ConfigurationParser::ParseSamplerConfiguration( const std::unique_ptr &node, size_t depth) { @@ -1308,7 +1330,8 @@ static std::unique_ptr ParseSamplerConfiguration( if (count != 1) { - std::string message("Illegal sampler, properties count: "); + std::string message = node->Location().ToString(); + message.append(", Illegal sampler, properties count: "); message.append(std::to_string(count)); throw InvalidSchemaException(message); } @@ -1342,7 +1365,8 @@ static std::unique_ptr ParseSamplerConfiguration( } // NOLINTEND(misc-no-recursion) -static std::unique_ptr ParseOtlpHttpSpanExporterConfiguration( +std::unique_ptr +ConfigurationParser::ParseOtlpHttpSpanExporterConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1369,7 +1393,8 @@ static std::unique_ptr ParseOtlpHttpSpanExpor return model; } -static std::unique_ptr ParseOtlpGrpcSpanExporterConfiguration( +std::unique_ptr +ConfigurationParser::ParseOtlpGrpcSpanExporterConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1394,7 +1419,8 @@ static std::unique_ptr ParseOtlpGrpcSpanExpor return model; } -static std::unique_ptr ParseOtlpFileSpanExporterConfiguration( +std::unique_ptr +ConfigurationParser::ParseOtlpFileSpanExporterConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1405,7 +1431,8 @@ static std::unique_ptr ParseOtlpFileSpanExpor return model; } -static std::unique_ptr ParseConsoleSpanExporterConfiguration( +std::unique_ptr +ConfigurationParser::ParseConsoleSpanExporterConfiguration( const std::unique_ptr & /* node */) { auto model = std::make_unique(); @@ -1413,8 +1440,8 @@ static std::unique_ptr ParseConsoleSpanExporte return model; } -static std::unique_ptr ParseZipkinSpanExporterConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseZipkinSpanExporterConfiguration(const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1424,9 +1451,9 @@ static std::unique_ptr ParseZipkinSpanExporterC return model; } -static std::unique_ptr ParseExtensionSpanExporterConfiguration( - const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParseExtensionSpanExporterConfiguration(const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -1436,7 +1463,7 @@ static std::unique_ptr ParseExtensionSpanExp return model; } -static std::unique_ptr ParseSpanExporterConfiguration( +std::unique_ptr ConfigurationParser::ParseSpanExporterConfiguration( const std::unique_ptr &node) { std::unique_ptr model; @@ -1487,8 +1514,8 @@ static std::unique_ptr ParseSpanExporterConfiguration return model; } -static std::unique_ptr ParseBatchSpanProcessorConfiguration( - const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseBatchSpanProcessorConfiguration(const std::unique_ptr &node) { auto model = std::make_unique(); std::unique_ptr child; @@ -1504,7 +1531,8 @@ static std::unique_ptr ParseBatchSpanProcessorC return model; } -static std::unique_ptr ParseSimpleSpanProcessorConfiguration( +std::unique_ptr +ConfigurationParser::ParseSimpleSpanProcessorConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1516,9 +1544,9 @@ static std::unique_ptr ParseSimpleSpanProcesso return model; } -static std::unique_ptr -ParseExtensionSpanProcessorConfiguration(const std::string &name, - std::unique_ptr node) +std::unique_ptr +ConfigurationParser::ParseExtensionSpanProcessorConfiguration(const std::string &name, + std::unique_ptr node) { auto model = std::make_unique(); @@ -1528,7 +1556,7 @@ ParseExtensionSpanProcessorConfiguration(const std::string &name, return model; } -static std::unique_ptr ParseSpanProcessorConfiguration( +std::unique_ptr ConfigurationParser::ParseSpanProcessorConfiguration( const std::unique_ptr &node) { std::unique_ptr model; @@ -1567,7 +1595,7 @@ static std::unique_ptr ParseSpanProcessorConfigurati return model; } -static std::unique_ptr ParseTracerProviderConfiguration( +std::unique_ptr ConfigurationParser::ParseTracerProviderConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1602,7 +1630,8 @@ static std::unique_ptr ParseTracerProviderConfigura return model; } -static std::unique_ptr ParseStringAttributeValueConfiguration( +std::unique_ptr +ConfigurationParser::ParseStringAttributeValueConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1612,7 +1641,8 @@ static std::unique_ptr ParseStringAttributeVa return model; } -static std::unique_ptr ParseIntegerAttributeValueConfiguration( +std::unique_ptr +ConfigurationParser::ParseIntegerAttributeValueConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1622,7 +1652,8 @@ static std::unique_ptr ParseIntegerAttribute return model; } -static std::unique_ptr ParseDoubleAttributeValueConfiguration( +std::unique_ptr +ConfigurationParser::ParseDoubleAttributeValueConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1632,7 +1663,8 @@ static std::unique_ptr ParseDoubleAttributeVa return model; } -static std::unique_ptr ParseBooleanAttributeValueConfiguration( +std::unique_ptr +ConfigurationParser::ParseBooleanAttributeValueConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1642,8 +1674,9 @@ static std::unique_ptr ParseBooleanAttribute return model; } -static std::unique_ptr -ParseStringArrayAttributeValueConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseStringArrayAttributeValueConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1659,8 +1692,9 @@ ParseStringArrayAttributeValueConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseIntegerArrayAttributeValueConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseIntegerArrayAttributeValueConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1676,8 +1710,9 @@ ParseIntegerArrayAttributeValueConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseDoubleArrayAttributeValueConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseDoubleArrayAttributeValueConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1693,8 +1728,9 @@ ParseDoubleArrayAttributeValueConfiguration(const std::unique_ptr return model; } -static std::unique_ptr -ParseBooleanArrayAttributeValueConfiguration(const std::unique_ptr &node) +std::unique_ptr +ConfigurationParser::ParseBooleanArrayAttributeValueConfiguration( + const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1710,7 +1746,7 @@ ParseBooleanArrayAttributeValueConfiguration(const std::unique_ptr return model; } -static std::unique_ptr ParseAttributesConfiguration( +std::unique_ptr ConfigurationParser::ParseAttributesConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1798,7 +1834,7 @@ static std::unique_ptr ParseAttributesConfiguration( return model; } -static std::unique_ptr ParseResourceConfiguration( +std::unique_ptr ConfigurationParser::ParseResourceConfiguration( const std::unique_ptr &node) { auto model = std::make_unique(); @@ -1829,7 +1865,33 @@ std::unique_ptr ConfigurationParser::Parse(std::unique_ptr(std::move(doc)); model->file_format = node->GetRequiredString("file_format"); - model->disabled = node->GetBoolean("disabled", false); + + { + int count; + int major; + int minor; + int patch; + + count = sscanf(model->file_format.c_str(), "%d.%d.%d", &major, &minor, &patch); + if (count != 3) + { + std::string message("Invalid file_format"); + throw InvalidSchemaException(message); + } + + if (major != 1) + { + std::string message("Unsupported file_format, major = "); + message.append(std::to_string(major)); + throw InvalidSchemaException(message); + } + + version_major_ = major; + version_minor_ = minor; + version_patch_ = patch; + } + + model->disabled = node->GetBoolean("disabled", false); std::unique_ptr child; diff --git a/sdk/src/configuration/sdk_builder.cc b/sdk/src/configuration/sdk_builder.cc index 0da1af86dc..ecbf9c4165 100644 --- a/sdk/src/configuration/sdk_builder.cc +++ b/sdk/src/configuration/sdk_builder.cc @@ -187,7 +187,9 @@ class ResourceAttributeValueSetter void VisitInteger( const opentelemetry::sdk::configuration::IntegerAttributeValueConfiguration *model) override { - opentelemetry::common::AttributeValue attribute_value(model->value); + /* Provide exact type to opentelemetry::common::AttributeValue variant. */ + int64_t value = model->value; + opentelemetry::common::AttributeValue attribute_value(value); resource_attributes_.SetAttribute(name_, attribute_value); } diff --git a/sdk/src/configuration/yaml_configuration_parser.cc b/sdk/src/configuration/yaml_configuration_parser.cc index 627849362e..665efa927a 100644 --- a/sdk/src/configuration/yaml_configuration_parser.cc +++ b/sdk/src/configuration/yaml_configuration_parser.cc @@ -66,6 +66,7 @@ std::unique_ptr YamlConfigurationParser::ParseString(const std::s { std::unique_ptr doc; std::unique_ptr config; + ConfigurationParser config_parser; doc = RymlDocument::Parse(source, content); @@ -73,7 +74,7 @@ std::unique_ptr YamlConfigurationParser::ParseString(const std::s { if (doc) { - config = ConfigurationParser::Parse(std::move(doc)); + config = config_parser.Parse(std::move(doc)); } } catch (const std::exception &e) diff --git a/sdk/test/configuration/yaml_logs_test.cc b/sdk/test/configuration/yaml_logs_test.cc index b38c7c58ed..9a4c069db6 100644 --- a/sdk/test/configuration/yaml_logs_test.cc +++ b/sdk/test/configuration/yaml_logs_test.cc @@ -30,7 +30,7 @@ static std::unique_ptr DoParse TEST(YamlLogs, no_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: )"; @@ -41,7 +41,7 @@ file_format: xx.yy TEST(YamlLogs, empty_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: )"; @@ -53,7 +53,7 @@ file_format: xx.yy TEST(YamlLogs, many_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -73,7 +73,7 @@ file_format: xx.yy TEST(YamlLogs, simple_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -98,7 +98,7 @@ file_format: xx.yy TEST(YamlLogs, default_batch_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - batch: @@ -127,7 +127,7 @@ file_format: xx.yy TEST(YamlLogs, batch_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - batch: @@ -160,7 +160,7 @@ file_format: xx.yy TEST(YamlLogs, default_otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -198,7 +198,7 @@ file_format: xx.yy TEST(YamlLogs, otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -251,7 +251,7 @@ file_format: xx.yy TEST(YamlLogs, default_otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -289,7 +289,7 @@ file_format: xx.yy TEST(YamlLogs, otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -342,7 +342,7 @@ file_format: xx.yy TEST(YamlLogs, default_otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -371,7 +371,7 @@ file_format: xx.yy TEST(YamlLogs, otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -401,7 +401,7 @@ file_format: xx.yy TEST(YamlLogs, otlp_console) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -426,7 +426,7 @@ file_format: xx.yy TEST(YamlLogs, no_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -443,7 +443,7 @@ file_format: xx.yy TEST(YamlLogs, default_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: @@ -463,7 +463,7 @@ file_format: xx.yy TEST(YamlLogs, limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-logs logger_provider: processors: - simple: diff --git a/sdk/test/configuration/yaml_metrics_test.cc b/sdk/test/configuration/yaml_metrics_test.cc index 4b202c2cf1..f08eff3e59 100644 --- a/sdk/test/configuration/yaml_metrics_test.cc +++ b/sdk/test/configuration/yaml_metrics_test.cc @@ -40,7 +40,7 @@ static std::unique_ptr DoParse TEST(YamlMetrics, no_readers) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: )"; @@ -51,7 +51,7 @@ file_format: xx.yy TEST(YamlMetrics, empty_readers) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: )"; @@ -63,7 +63,7 @@ file_format: xx.yy TEST(YamlMetrics, many_readers) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -83,7 +83,7 @@ file_format: xx.yy TEST(YamlMetrics, default_periodic_reader) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -110,7 +110,7 @@ file_format: xx.yy TEST(YamlMetrics, periodic_reader) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -139,7 +139,7 @@ file_format: xx.yy TEST(YamlMetrics, pull_reader) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - pull: @@ -163,7 +163,7 @@ file_format: xx.yy TEST(YamlMetrics, default_otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -205,7 +205,7 @@ file_format: xx.yy TEST(YamlMetrics, otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -264,7 +264,7 @@ file_format: xx.yy TEST(YamlMetrics, default_otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -306,7 +306,7 @@ file_format: xx.yy TEST(YamlMetrics, otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -365,7 +365,7 @@ file_format: xx.yy TEST(YamlMetrics, default_otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -398,7 +398,7 @@ file_format: xx.yy TEST(YamlMetrics, otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -434,7 +434,7 @@ file_format: xx.yy TEST(YamlMetrics, default_console) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -473,7 +473,7 @@ file_format: xx.yy TEST(YamlMetrics, console) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -514,7 +514,7 @@ file_format: xx.yy TEST(YamlMetrics, default_prometheus) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - pull: @@ -545,7 +545,7 @@ file_format: xx.yy TEST(YamlMetrics, prometheus) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - pull: @@ -581,7 +581,7 @@ file_format: xx.yy TEST(YamlMetrics, empty_views) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -599,7 +599,7 @@ file_format: xx.yy TEST(YamlMetrics, default_views) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -635,7 +635,7 @@ file_format: xx.yy TEST(YamlMetrics, selector) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -677,7 +677,7 @@ file_format: xx.yy TEST(YamlMetrics, stream) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -716,7 +716,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_default) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -744,7 +744,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_drop) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -772,7 +772,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_explicit_bucket_histogram) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -814,7 +814,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_base2_exponential_bucket_histogram) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -852,7 +852,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_last_value) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -880,7 +880,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_aggregation_sum) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: @@ -908,7 +908,7 @@ file_format: xx.yy TEST(YamlMetrics, stream_attribute_keys) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-metrics meter_provider: readers: - periodic: diff --git a/sdk/test/configuration/yaml_propagator_test.cc b/sdk/test/configuration/yaml_propagator_test.cc index cba8bde4da..9c7fc0246c 100644 --- a/sdk/test/configuration/yaml_propagator_test.cc +++ b/sdk/test/configuration/yaml_propagator_test.cc @@ -20,7 +20,7 @@ static std::unique_ptr DoParse TEST(YamlPropagator, empty_propagator) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: )"; @@ -34,7 +34,7 @@ file_format: xx.yy TEST(YamlPropagator, empty_composite) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: )"; @@ -50,7 +50,7 @@ TEST(YamlPropagator, old_propagator_1) { // This is the old format, must fail std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: - foo @@ -65,7 +65,7 @@ TEST(YamlPropagator, old_propagator_2) { // This is the old format, must fail std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: [foo, bar] )"; @@ -77,7 +77,7 @@ file_format: xx.yy TEST(YamlPropagator, propagator_array_ok) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: - foo: @@ -98,7 +98,7 @@ file_format: xx.yy TEST(YamlPropagator, propagator_array_broken) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: - foo: @@ -113,7 +113,7 @@ file_format: xx.yy TEST(YamlPropagator, propagator_composite_list) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite_list: "foo,bar,baz" )"; @@ -128,7 +128,7 @@ file_format: xx.yy TEST(YamlPropagator, propagator_both) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: - aaa: @@ -150,7 +150,7 @@ file_format: xx.yy TEST(YamlPropagator, propagator_duplicates) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-propagator propagator: composite: - aaa: diff --git a/sdk/test/configuration/yaml_resource_test.cc b/sdk/test/configuration/yaml_resource_test.cc index 69386928e3..3ff1882a5c 100644 --- a/sdk/test/configuration/yaml_resource_test.cc +++ b/sdk/test/configuration/yaml_resource_test.cc @@ -26,7 +26,7 @@ static std::unique_ptr DoParse TEST(YamlResource, empty_resource) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: )"; @@ -41,7 +41,7 @@ file_format: xx.yy TEST(YamlResource, empty_attributes) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes: )"; @@ -57,7 +57,7 @@ TEST(YamlResource, some_attributes_0_10) { // This is the old 0.10 format, must fail std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes: foo: "1234" @@ -72,7 +72,7 @@ TEST(YamlResource, some_attributes_0_30) { // This is the new 0.30 format, must pass std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes: - name: foo @@ -111,7 +111,7 @@ file_format: xx.yy TEST(YamlResource, empty_attributes_list) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes_list: )"; @@ -125,7 +125,7 @@ file_format: xx.yy TEST(YamlResource, some_attributes_list) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes_list: "foo=1234,bar=5678" )"; @@ -140,7 +140,7 @@ TEST(YamlResource, both_0_10) { // This is the old 0.10 format, must fail std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes: foo: "1234" @@ -156,7 +156,7 @@ TEST(YamlResource, both_0_30) { // This is the new 0.30 format, must pass std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: attributes: - name: foo @@ -198,7 +198,7 @@ file_format: xx.yy TEST(YamlResource, empty_detectors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: detectors: )"; @@ -214,7 +214,7 @@ file_format: xx.yy TEST(YamlResource, empty_included_detectors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: detectors: included: @@ -232,7 +232,7 @@ file_format: xx.yy TEST(YamlResource, some_included_detectors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: detectors: included: @@ -254,7 +254,7 @@ file_format: xx.yy TEST(YamlResource, some_excluded_detectors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: detectors: excluded: @@ -276,7 +276,7 @@ file_format: xx.yy TEST(YamlResource, some_detectors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-resource resource: detectors: included: diff --git a/sdk/test/configuration/yaml_test.cc b/sdk/test/configuration/yaml_test.cc index 6a62f65429..b637b554db 100644 --- a/sdk/test/configuration/yaml_test.cc +++ b/sdk/test/configuration/yaml_test.cc @@ -12,6 +12,12 @@ #include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" #include "opentelemetry/sdk/configuration/yaml_configuration_parser.h" +#if defined(_MSC_VER) +# include "opentelemetry/sdk/common/env_variables.h" +using opentelemetry::sdk::common::setenv; +using opentelemetry::sdk::common::unsetenv; +#endif + static std::unique_ptr DoParse( const std::string &yaml) { @@ -37,59 +43,120 @@ TEST(Yaml, no_format) ASSERT_EQ(config, nullptr); } -TEST(Yaml, just_format) +TEST(Yaml, broken_format) { std::string yaml = R"( file_format: xx.yy +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(Yaml, broken_minor_format) +{ + std::string yaml = R"( +file_format: 1.yy +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(Yaml, broken_patch_format) +{ + std::string yaml = R"( +file_format: 1.0.zz +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(Yaml, unsupported_old_format) +{ + std::string yaml = R"( +file_format: 0.99.99 +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(Yaml, unsupported_new_format) +{ + std::string yaml = R"( +file_format: 2.0.0 +)"; + + auto config = DoParse(yaml); + ASSERT_EQ(config, nullptr); +} + +TEST(Yaml, supported_new_format) +{ + std::string yaml = R"( +file_format: 1.9.9 +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_EQ(config->file_format, "1.9.9"); +} + +TEST(Yaml, just_format) +{ + std::string yaml = R"( +file_format: 1.0.0-rc.1 )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0-rc.1"); } TEST(Yaml, disabled) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 disabled: true )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0"); ASSERT_EQ(config->disabled, true); } TEST(Yaml, enabled) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 disabled: false )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0"); ASSERT_EQ(config->disabled, false); } TEST(Yaml, enabled_by_default) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0"); ASSERT_EQ(config->disabled, false); } TEST(Yaml, no_attribute_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 )"; auto config = DoParse(yaml); @@ -100,13 +167,13 @@ file_format: xx.yy TEST(Yaml, empty_attribute_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 attribute_limits: )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0"); ASSERT_NE(config->attribute_limits, nullptr); ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 4096); ASSERT_EQ(config->attribute_limits->attribute_count_limit, 128); @@ -115,7 +182,7 @@ file_format: xx.yy TEST(Yaml, attribute_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0 attribute_limits: attribute_value_length_limit: 1234 attribute_count_limit: 5678 @@ -123,7 +190,7 @@ file_format: xx.yy auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "xx.yy"); + ASSERT_EQ(config->file_format, "1.0.0"); ASSERT_NE(config->attribute_limits, nullptr); ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 1234); ASSERT_EQ(config->attribute_limits->attribute_count_limit, 5678); @@ -132,7 +199,7 @@ file_format: xx.yy TEST(Yaml, no_optional_boolean) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: )"; @@ -144,7 +211,7 @@ file_format: 0.0 TEST(Yaml, illegal_boolean) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: illegal )"; @@ -157,7 +224,7 @@ TEST(Yaml, no_boolean_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME} )"; @@ -171,7 +238,7 @@ TEST(Yaml, no_boolean_substitution_env) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${env:ENV_NAME} )"; @@ -185,7 +252,7 @@ TEST(Yaml, empty_boolean_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME} )"; @@ -199,7 +266,7 @@ TEST(Yaml, empty_boolean_substitution_env) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${env:ENV_NAME} )"; @@ -213,7 +280,7 @@ TEST(Yaml, true_boolean_substitution) setenv("ENV_NAME", "true", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME} )"; @@ -227,7 +294,7 @@ TEST(Yaml, false_boolean_substitution) setenv("ENV_NAME", "false", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME} )"; @@ -241,7 +308,7 @@ TEST(Yaml, illegal_boolean_substitution) setenv("ENV_NAME", "illegal", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME} )"; @@ -254,7 +321,7 @@ TEST(Yaml, empty_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME:-} )"; @@ -268,7 +335,7 @@ TEST(Yaml, true_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME:-true} )"; @@ -282,7 +349,7 @@ TEST(Yaml, false_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME:-false} )"; @@ -296,7 +363,7 @@ TEST(Yaml, illegal_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${ENV_NAME:-illegal} )"; @@ -309,7 +376,7 @@ TEST(Yaml, torture_boolean_substitution_fallback) setenv("env", "true", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 disabled: ${env:-false} )"; @@ -378,7 +445,7 @@ file_format: ${env:ENV_NAME} TEST(Yaml, with_string_substitution) { - setenv("ENV_NAME", "foo.bar", 1); + setenv("ENV_NAME", "1.0.0-substitution", 1); std::string yaml = R"( file_format: ${ENV_NAME} @@ -386,12 +453,12 @@ file_format: ${ENV_NAME} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "foo.bar"); + ASSERT_EQ(config->file_format, "1.0.0-substitution"); } TEST(Yaml, with_string_substitution_env) { - setenv("ENV_NAME", "foo.bar", 1); + setenv("ENV_NAME", "1.0.0-substitution", 1); std::string yaml = R"( file_format: ${env:ENV_NAME} @@ -399,7 +466,7 @@ file_format: ${env:ENV_NAME} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "foo.bar"); + ASSERT_EQ(config->file_format, "1.0.0-substitution"); } TEST(Yaml, with_string_substitution_fallback) @@ -407,19 +474,19 @@ TEST(Yaml, with_string_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: ${env:ENV_NAME:-foo.bar} +file_format: ${env:ENV_NAME:-1.0.0-fallback} )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "foo.bar"); + ASSERT_EQ(config->file_format, "1.0.0-fallback"); } TEST(Yaml, multiple_string_substitution) { - setenv("PREFIX", "foo", 1); + setenv("PREFIX", "1", 1); unsetenv("DOT"); - setenv("SUFFIX", "bar", 1); + setenv("SUFFIX", "2.3", 1); std::string yaml = R"( file_format: ${env:PREFIX:-failed}${DOT:-.}${SUFFIX:-failed} @@ -427,13 +494,13 @@ file_format: ${env:PREFIX:-failed}${DOT:-.}${SUFFIX:-failed} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "foo.bar"); + ASSERT_EQ(config->file_format, "1.2.3"); } TEST(Yaml, no_optional_integer) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: )"; @@ -447,7 +514,7 @@ file_format: 0.0 TEST(Yaml, illegal_integer) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: "just enough" )"; @@ -461,7 +528,7 @@ TEST(Yaml, no_integer_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -477,7 +544,7 @@ TEST(Yaml, empty_integer_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -493,7 +560,7 @@ TEST(Yaml, with_integer_substitution) setenv("ENV_NAME", "7777", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -509,7 +576,7 @@ TEST(Yaml, with_illegal_integer_substitution) setenv("ENV_NAME", "still not enough", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -521,7 +588,7 @@ file_format: 0.0 TEST(Yaml, no_optional_double) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: @@ -546,7 +613,7 @@ file_format: 0.0 TEST(Yaml, illegal_double) { std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: @@ -566,7 +633,7 @@ TEST(Yaml, no_double_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: @@ -593,7 +660,7 @@ TEST(Yaml, empty_double_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: @@ -620,7 +687,7 @@ TEST(Yaml, with_double_substitution) setenv("ENV_NAME", "3.14", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: @@ -647,7 +714,7 @@ TEST(Yaml, with_illegal_double_substitution) setenv("ENV_NAME", "something else", 1); std::string yaml = R"( -file_format: 0.0 +file_format: 1.0.0 tracer_provider: processors: - simple: diff --git a/sdk/test/configuration/yaml_trace_test.cc b/sdk/test/configuration/yaml_trace_test.cc index f5f53c7419..5438874052 100644 --- a/sdk/test/configuration/yaml_trace_test.cc +++ b/sdk/test/configuration/yaml_trace_test.cc @@ -34,7 +34,7 @@ static std::unique_ptr DoParse TEST(YamlTrace, no_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: )"; @@ -45,7 +45,7 @@ file_format: xx.yy TEST(YamlTrace, empty_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: )"; @@ -57,7 +57,7 @@ file_format: xx.yy TEST(YamlTrace, many_processors) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -77,7 +77,7 @@ file_format: xx.yy TEST(YamlTrace, simple_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -102,7 +102,7 @@ file_format: xx.yy TEST(YamlTrace, default_batch_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - batch: @@ -131,7 +131,7 @@ file_format: xx.yy TEST(YamlTrace, batch_processor) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - batch: @@ -164,7 +164,7 @@ file_format: xx.yy TEST(YamlTrace, default_otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -202,7 +202,7 @@ file_format: xx.yy TEST(YamlTrace, otlp_http) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -255,7 +255,7 @@ file_format: xx.yy TEST(YamlTrace, default_otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -293,7 +293,7 @@ file_format: xx.yy TEST(YamlTrace, otlp_grpc) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -346,7 +346,7 @@ file_format: xx.yy TEST(YamlTrace, default_otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -375,7 +375,7 @@ file_format: xx.yy TEST(YamlTrace, otlp_file) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -405,7 +405,7 @@ file_format: xx.yy TEST(YamlTrace, otlp_console) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -430,7 +430,7 @@ file_format: xx.yy TEST(YamlTrace, default_otlp_zipkin) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -461,7 +461,7 @@ file_format: xx.yy TEST(YamlTrace, otlp_zipkin) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -493,7 +493,7 @@ file_format: xx.yy TEST(YamlTrace, no_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -510,7 +510,7 @@ file_format: xx.yy TEST(YamlTrace, default_limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -534,7 +534,7 @@ file_format: xx.yy TEST(YamlTrace, limits) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -564,7 +564,7 @@ file_format: xx.yy TEST(YamlTrace, no_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -581,7 +581,7 @@ file_format: xx.yy TEST(YamlTrace, empty_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -597,7 +597,7 @@ file_format: xx.yy TEST(YamlTrace, many_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -615,7 +615,7 @@ file_format: xx.yy TEST(YamlTrace, always_off_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -634,7 +634,7 @@ file_format: xx.yy TEST(YamlTrace, always_on_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -653,7 +653,7 @@ file_format: xx.yy TEST(YamlTrace, jaeger_remote_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -683,7 +683,7 @@ file_format: xx.yy TEST(YamlTrace, default_parent_based_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -711,7 +711,7 @@ file_format: xx.yy TEST(YamlTrace, parent_based_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -749,7 +749,7 @@ file_format: xx.yy TEST(YamlTrace, default_trace_id_ratio_based_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: @@ -773,7 +773,7 @@ file_format: xx.yy TEST(YamlTrace, trace_id_ratio_based_sampler) { std::string yaml = R"( -file_format: xx.yy +file_format: 1.0.0-trace tracer_provider: processors: - simple: diff --git a/tbump.toml b/tbump.toml index 59412f584e..2cb6d8dd3a 100644 --- a/tbump.toml +++ b/tbump.toml @@ -123,6 +123,10 @@ search = "short_version\\s*= [\"]{current_version}[\"]" src = "sdk/src/version/version.cc" search = "full_version\\s*= ['\"]{current_version}['\"]" +[[file]] +src = "functional/configuration/shelltests/kitchen-sink.test" +search = "telemetry.sdk.version: {current_version}" + # You can specify a list of commands to # run after the files have been patched From 1621ae575ddecaa2fff716c421d1acd202059e60 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 18 Sep 2025 22:18:19 +0200 Subject: [PATCH 2/4] file format cleanup, only major and minor. --- examples/configuration/extensions.yaml | 2 +- .../shelltests/kitchen-sink.yaml | 2 +- .../shelltests/propagator_both.yaml | 2 +- .../shelltests/propagator_broken.yaml | 2 +- .../shelltests/propagator_composite_list.yaml | 2 +- .../shelltests/propagator_duplicates.yaml | 2 +- .../shelltests/propagator_multi.yaml | 2 +- .../shelltests/propagator_ottrace.yaml | 2 +- .../shelltests/propagator_single.yaml | 2 +- .../shelltests/propagator_unknown.yaml | 2 +- .../shelltests/propagator_xray.yaml | 2 +- .../shelltests/sampler_jaeger.yaml | 2 +- .../sdk/configuration/configuration_parser.h | 1 - sdk/src/configuration/configuration_parser.cc | 15 ++- sdk/test/configuration/yaml_logs_test.cc | 32 ++--- sdk/test/configuration/yaml_metrics_test.cc | 54 ++++---- .../configuration/yaml_propagator_test.cc | 18 +-- sdk/test/configuration/yaml_resource_test.cc | 26 ++-- sdk/test/configuration/yaml_test.cc | 121 ++++++++---------- sdk/test/configuration/yaml_trace_test.cc | 56 ++++---- 20 files changed, 171 insertions(+), 176 deletions(-) diff --git a/examples/configuration/extensions.yaml b/examples/configuration/extensions.yaml index 2ca218d251..1c7aa47313 100644 --- a/examples/configuration/extensions.yaml +++ b/examples/configuration/extensions.yaml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 # The file format version -file_format: "0.1" +file_format: "1.0" # Configure if the SDK is disabled or not. This is not required to be provided # to ensure the SDK isn't disabled, the default value when this is not provided diff --git a/functional/configuration/shelltests/kitchen-sink.yaml b/functional/configuration/shelltests/kitchen-sink.yaml index 154f1a8d5a..de8d00be68 100644 --- a/functional/configuration/shelltests/kitchen-sink.yaml +++ b/functional/configuration/shelltests/kitchen-sink.yaml @@ -11,7 +11,7 @@ # The file format version. # The yaml format is documented at # https://github.com/open-telemetry/opentelemetry-configuration/tree/main/schema -file_format: "1.0.0-rc.1" +file_format: "1.0-rc.1" # Configure if the SDK is disabled or not. # If omitted or null, false is used. disabled: false diff --git a/functional/configuration/shelltests/propagator_both.yaml b/functional/configuration/shelltests/propagator_both.yaml index 6e4e4e6fd9..ef8dcf12f8 100644 --- a/functional/configuration/shelltests/propagator_both.yaml +++ b/functional/configuration/shelltests/propagator_both.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_broken.yaml b/functional/configuration/shelltests/propagator_broken.yaml index ddad6d9eeb..9f3a157eda 100644 --- a/functional/configuration/shelltests/propagator_broken.yaml +++ b/functional/configuration/shelltests/propagator_broken.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_composite_list.yaml b/functional/configuration/shelltests/propagator_composite_list.yaml index 26a6030a22..5d9a6b6245 100644 --- a/functional/configuration/shelltests/propagator_composite_list.yaml +++ b/functional/configuration/shelltests/propagator_composite_list.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite_list: "tracecontext,baggage,b3,b3multi" diff --git a/functional/configuration/shelltests/propagator_duplicates.yaml b/functional/configuration/shelltests/propagator_duplicates.yaml index df371636e5..06f3d374a7 100644 --- a/functional/configuration/shelltests/propagator_duplicates.yaml +++ b/functional/configuration/shelltests/propagator_duplicates.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_multi.yaml b/functional/configuration/shelltests/propagator_multi.yaml index d1aec0864f..7fcd96b53a 100644 --- a/functional/configuration/shelltests/propagator_multi.yaml +++ b/functional/configuration/shelltests/propagator_multi.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_ottrace.yaml b/functional/configuration/shelltests/propagator_ottrace.yaml index 221022e965..1c12a48b15 100644 --- a/functional/configuration/shelltests/propagator_ottrace.yaml +++ b/functional/configuration/shelltests/propagator_ottrace.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_single.yaml b/functional/configuration/shelltests/propagator_single.yaml index 7b1a6bd91a..e957d3f84a 100644 --- a/functional/configuration/shelltests/propagator_single.yaml +++ b/functional/configuration/shelltests/propagator_single.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_unknown.yaml b/functional/configuration/shelltests/propagator_unknown.yaml index 38eb157513..3c1587c2a7 100644 --- a/functional/configuration/shelltests/propagator_unknown.yaml +++ b/functional/configuration/shelltests/propagator_unknown.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/propagator_xray.yaml b/functional/configuration/shelltests/propagator_xray.yaml index 872968d000..c825729cb0 100644 --- a/functional/configuration/shelltests/propagator_xray.yaml +++ b/functional/configuration/shelltests/propagator_xray.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" propagator: composite: diff --git a/functional/configuration/shelltests/sampler_jaeger.yaml b/functional/configuration/shelltests/sampler_jaeger.yaml index c4d4a819a4..687f5de9e1 100644 --- a/functional/configuration/shelltests/sampler_jaeger.yaml +++ b/functional/configuration/shelltests/sampler_jaeger.yaml @@ -1,7 +1,7 @@ # Copyright The OpenTelemetry Authors # SPDX-License-Identifier: Apache-2.0 -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: diff --git a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h index 392a4b0798..b8b682e332 100644 --- a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h +++ b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h @@ -348,7 +348,6 @@ class ConfigurationParser std::string version_; int version_major_; int version_minor_; - int version_patch_; }; } // namespace configuration diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index da26865aec..83768a3354 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -1870,10 +1870,9 @@ std::unique_ptr ConfigurationParser::Parse(std::unique_ptrfile_format.c_str(), "%d.%d.%d", &major, &minor, &patch); - if (count != 3) + count = sscanf(model->file_format.c_str(), "%d.%d", &major, &minor); + if (count != 2) { std::string message("Invalid file_format"); throw InvalidSchemaException(message); @@ -1886,9 +1885,17 @@ std::unique_ptr ConfigurationParser::Parse(std::unique_ptr DoParse TEST(YamlLogs, no_processors) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: )"; @@ -41,7 +41,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, empty_processors) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: )"; @@ -53,7 +53,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, many_processors) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -73,7 +73,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, simple_processor) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -98,7 +98,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, default_batch_processor) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - batch: @@ -127,7 +127,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, batch_processor) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - batch: @@ -160,7 +160,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, default_otlp_http) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -198,7 +198,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, otlp_http) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -251,7 +251,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, default_otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -289,7 +289,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -342,7 +342,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, default_otlp_file) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -371,7 +371,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, otlp_file) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -401,7 +401,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, otlp_console) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -426,7 +426,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, no_limits) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -443,7 +443,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, default_limits) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: @@ -463,7 +463,7 @@ file_format: 1.0.0-logs TEST(YamlLogs, limits) { std::string yaml = R"( -file_format: 1.0.0-logs +file_format: "1.0-logs" logger_provider: processors: - simple: diff --git a/sdk/test/configuration/yaml_metrics_test.cc b/sdk/test/configuration/yaml_metrics_test.cc index f08eff3e59..f063c55145 100644 --- a/sdk/test/configuration/yaml_metrics_test.cc +++ b/sdk/test/configuration/yaml_metrics_test.cc @@ -40,7 +40,7 @@ static std::unique_ptr DoParse TEST(YamlMetrics, no_readers) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: )"; @@ -51,7 +51,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, empty_readers) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: )"; @@ -63,7 +63,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, many_readers) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -83,7 +83,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_periodic_reader) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -110,7 +110,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, periodic_reader) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -139,7 +139,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, pull_reader) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - pull: @@ -163,7 +163,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_otlp_http) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -205,7 +205,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, otlp_http) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -264,7 +264,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -306,7 +306,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -365,7 +365,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_otlp_file) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -398,7 +398,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, otlp_file) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -434,7 +434,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_console) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -473,7 +473,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, console) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -514,7 +514,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_prometheus) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - pull: @@ -545,7 +545,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, prometheus) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - pull: @@ -581,7 +581,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, empty_views) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -599,7 +599,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, default_views) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -635,7 +635,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, selector) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -677,7 +677,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -716,7 +716,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_default) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -744,7 +744,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_drop) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -772,7 +772,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_explicit_bucket_histogram) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -814,7 +814,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_base2_exponential_bucket_histogram) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -852,7 +852,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_last_value) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -880,7 +880,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_aggregation_sum) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: @@ -908,7 +908,7 @@ file_format: 1.0.0-metrics TEST(YamlMetrics, stream_attribute_keys) { std::string yaml = R"( -file_format: 1.0.0-metrics +file_format: "1.0-metrics" meter_provider: readers: - periodic: diff --git a/sdk/test/configuration/yaml_propagator_test.cc b/sdk/test/configuration/yaml_propagator_test.cc index 9c7fc0246c..78daf6dfae 100644 --- a/sdk/test/configuration/yaml_propagator_test.cc +++ b/sdk/test/configuration/yaml_propagator_test.cc @@ -20,7 +20,7 @@ static std::unique_ptr DoParse TEST(YamlPropagator, empty_propagator) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: )"; @@ -34,7 +34,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, empty_composite) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: )"; @@ -50,7 +50,7 @@ TEST(YamlPropagator, old_propagator_1) { // This is the old format, must fail std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: - foo @@ -65,7 +65,7 @@ TEST(YamlPropagator, old_propagator_2) { // This is the old format, must fail std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: [foo, bar] )"; @@ -77,7 +77,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, propagator_array_ok) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: - foo: @@ -98,7 +98,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, propagator_array_broken) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: - foo: @@ -113,7 +113,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, propagator_composite_list) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite_list: "foo,bar,baz" )"; @@ -128,7 +128,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, propagator_both) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: - aaa: @@ -150,7 +150,7 @@ file_format: 1.0.0-propagator TEST(YamlPropagator, propagator_duplicates) { std::string yaml = R"( -file_format: 1.0.0-propagator +file_format: "1.0-propagator" propagator: composite: - aaa: diff --git a/sdk/test/configuration/yaml_resource_test.cc b/sdk/test/configuration/yaml_resource_test.cc index 3ff1882a5c..87685277af 100644 --- a/sdk/test/configuration/yaml_resource_test.cc +++ b/sdk/test/configuration/yaml_resource_test.cc @@ -26,7 +26,7 @@ static std::unique_ptr DoParse TEST(YamlResource, empty_resource) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: )"; @@ -41,7 +41,7 @@ file_format: 1.0.0-resource TEST(YamlResource, empty_attributes) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes: )"; @@ -57,7 +57,7 @@ TEST(YamlResource, some_attributes_0_10) { // This is the old 0.10 format, must fail std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes: foo: "1234" @@ -72,7 +72,7 @@ TEST(YamlResource, some_attributes_0_30) { // This is the new 0.30 format, must pass std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes: - name: foo @@ -111,7 +111,7 @@ file_format: 1.0.0-resource TEST(YamlResource, empty_attributes_list) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes_list: )"; @@ -125,7 +125,7 @@ file_format: 1.0.0-resource TEST(YamlResource, some_attributes_list) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes_list: "foo=1234,bar=5678" )"; @@ -140,7 +140,7 @@ TEST(YamlResource, both_0_10) { // This is the old 0.10 format, must fail std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes: foo: "1234" @@ -156,7 +156,7 @@ TEST(YamlResource, both_0_30) { // This is the new 0.30 format, must pass std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: attributes: - name: foo @@ -198,7 +198,7 @@ file_format: 1.0.0-resource TEST(YamlResource, empty_detectors) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: detectors: )"; @@ -214,7 +214,7 @@ file_format: 1.0.0-resource TEST(YamlResource, empty_included_detectors) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: detectors: included: @@ -232,7 +232,7 @@ file_format: 1.0.0-resource TEST(YamlResource, some_included_detectors) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: detectors: included: @@ -254,7 +254,7 @@ file_format: 1.0.0-resource TEST(YamlResource, some_excluded_detectors) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: detectors: excluded: @@ -276,7 +276,7 @@ file_format: 1.0.0-resource TEST(YamlResource, some_detectors) { std::string yaml = R"( -file_format: 1.0.0-resource +file_format: "1.0-resource" resource: detectors: included: diff --git a/sdk/test/configuration/yaml_test.cc b/sdk/test/configuration/yaml_test.cc index b637b554db..9b8f2212f9 100644 --- a/sdk/test/configuration/yaml_test.cc +++ b/sdk/test/configuration/yaml_test.cc @@ -46,7 +46,7 @@ TEST(Yaml, no_format) TEST(Yaml, broken_format) { std::string yaml = R"( -file_format: xx.yy +file_format: "xx.yy" )"; auto config = DoParse(yaml); @@ -56,17 +56,7 @@ file_format: xx.yy TEST(Yaml, broken_minor_format) { std::string yaml = R"( -file_format: 1.yy -)"; - - auto config = DoParse(yaml); - ASSERT_EQ(config, nullptr); -} - -TEST(Yaml, broken_patch_format) -{ - std::string yaml = R"( -file_format: 1.0.zz +file_format: "1.yy" )"; auto config = DoParse(yaml); @@ -76,87 +66,86 @@ file_format: 1.0.zz TEST(Yaml, unsupported_old_format) { std::string yaml = R"( -file_format: 0.99.99 +file_format: "0.99" )"; auto config = DoParse(yaml); ASSERT_EQ(config, nullptr); } -TEST(Yaml, unsupported_new_format) +TEST(Yaml, unsupported_new_major_format) { std::string yaml = R"( -file_format: 2.0.0 +file_format: "2.0" )"; auto config = DoParse(yaml); ASSERT_EQ(config, nullptr); } -TEST(Yaml, supported_new_format) +TEST(Yaml, unsupported_new_minor_format) { std::string yaml = R"( -file_format: 1.9.9 +file_format: "1.1" )"; auto config = DoParse(yaml); - ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.9.9"); + ASSERT_EQ(config, nullptr); } TEST(Yaml, just_format) { std::string yaml = R"( -file_format: 1.0.0-rc.1 +file_format: "1.0-rc.1" )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0-rc.1"); + ASSERT_EQ(config->file_format, "1.0-rc.1"); } TEST(Yaml, disabled) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: true )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0"); + ASSERT_EQ(config->file_format, "1.0"); ASSERT_EQ(config->disabled, true); } TEST(Yaml, enabled) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: false )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0"); + ASSERT_EQ(config->file_format, "1.0"); ASSERT_EQ(config->disabled, false); } TEST(Yaml, enabled_by_default) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0"); + ASSERT_EQ(config->file_format, "1.0"); ASSERT_EQ(config->disabled, false); } TEST(Yaml, no_attribute_limits) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" )"; auto config = DoParse(yaml); @@ -167,13 +156,13 @@ file_format: 1.0.0 TEST(Yaml, empty_attribute_limits) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0"); + ASSERT_EQ(config->file_format, "1.0"); ASSERT_NE(config->attribute_limits, nullptr); ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 4096); ASSERT_EQ(config->attribute_limits->attribute_count_limit, 128); @@ -182,7 +171,7 @@ file_format: 1.0.0 TEST(Yaml, attribute_limits) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_value_length_limit: 1234 attribute_count_limit: 5678 @@ -190,7 +179,7 @@ file_format: 1.0.0 auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0"); + ASSERT_EQ(config->file_format, "1.0"); ASSERT_NE(config->attribute_limits, nullptr); ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 1234); ASSERT_EQ(config->attribute_limits->attribute_count_limit, 5678); @@ -199,7 +188,7 @@ file_format: 1.0.0 TEST(Yaml, no_optional_boolean) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: )"; @@ -211,7 +200,7 @@ file_format: 1.0.0 TEST(Yaml, illegal_boolean) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: illegal )"; @@ -224,7 +213,7 @@ TEST(Yaml, no_boolean_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME} )"; @@ -238,7 +227,7 @@ TEST(Yaml, no_boolean_substitution_env) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${env:ENV_NAME} )"; @@ -252,7 +241,7 @@ TEST(Yaml, empty_boolean_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME} )"; @@ -266,7 +255,7 @@ TEST(Yaml, empty_boolean_substitution_env) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${env:ENV_NAME} )"; @@ -280,7 +269,7 @@ TEST(Yaml, true_boolean_substitution) setenv("ENV_NAME", "true", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME} )"; @@ -294,7 +283,7 @@ TEST(Yaml, false_boolean_substitution) setenv("ENV_NAME", "false", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME} )"; @@ -308,7 +297,7 @@ TEST(Yaml, illegal_boolean_substitution) setenv("ENV_NAME", "illegal", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME} )"; @@ -321,7 +310,7 @@ TEST(Yaml, empty_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME:-} )"; @@ -335,7 +324,7 @@ TEST(Yaml, true_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME:-true} )"; @@ -349,7 +338,7 @@ TEST(Yaml, false_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME:-false} )"; @@ -363,7 +352,7 @@ TEST(Yaml, illegal_boolean_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${ENV_NAME:-illegal} )"; @@ -376,7 +365,7 @@ TEST(Yaml, torture_boolean_substitution_fallback) setenv("env", "true", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" disabled: ${env:-false} )"; @@ -445,7 +434,7 @@ file_format: ${env:ENV_NAME} TEST(Yaml, with_string_substitution) { - setenv("ENV_NAME", "1.0.0-substitution", 1); + setenv("ENV_NAME", "1.0-substitution", 1); std::string yaml = R"( file_format: ${ENV_NAME} @@ -453,12 +442,12 @@ file_format: ${ENV_NAME} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0-substitution"); + ASSERT_EQ(config->file_format, "1.0-substitution"); } TEST(Yaml, with_string_substitution_env) { - setenv("ENV_NAME", "1.0.0-substitution", 1); + setenv("ENV_NAME", "1.0-substitution", 1); std::string yaml = R"( file_format: ${env:ENV_NAME} @@ -466,7 +455,7 @@ file_format: ${env:ENV_NAME} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0-substitution"); + ASSERT_EQ(config->file_format, "1.0-substitution"); } TEST(Yaml, with_string_substitution_fallback) @@ -474,19 +463,19 @@ TEST(Yaml, with_string_substitution_fallback) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: ${env:ENV_NAME:-1.0.0-fallback} +file_format: ${env:ENV_NAME:-1.0-fallback} )"; auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.0.0-fallback"); + ASSERT_EQ(config->file_format, "1.0-fallback"); } TEST(Yaml, multiple_string_substitution) { setenv("PREFIX", "1", 1); unsetenv("DOT"); - setenv("SUFFIX", "2.3", 1); + setenv("SUFFIX", "0", 1); std::string yaml = R"( file_format: ${env:PREFIX:-failed}${DOT:-.}${SUFFIX:-failed} @@ -494,13 +483,13 @@ file_format: ${env:PREFIX:-failed}${DOT:-.}${SUFFIX:-failed} auto config = DoParse(yaml); ASSERT_NE(config, nullptr); - ASSERT_EQ(config->file_format, "1.2.3"); + ASSERT_EQ(config->file_format, "1.0"); } TEST(Yaml, no_optional_integer) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: )"; @@ -514,7 +503,7 @@ file_format: 1.0.0 TEST(Yaml, illegal_integer) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: "just enough" )"; @@ -528,7 +517,7 @@ TEST(Yaml, no_integer_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -544,7 +533,7 @@ TEST(Yaml, empty_integer_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -560,7 +549,7 @@ TEST(Yaml, with_integer_substitution) setenv("ENV_NAME", "7777", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -576,7 +565,7 @@ TEST(Yaml, with_illegal_integer_substitution) setenv("ENV_NAME", "still not enough", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" attribute_limits: attribute_count_limit: ${ENV_NAME} )"; @@ -588,7 +577,7 @@ file_format: 1.0.0 TEST(Yaml, no_optional_double) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: @@ -613,7 +602,7 @@ file_format: 1.0.0 TEST(Yaml, illegal_double) { std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: @@ -633,7 +622,7 @@ TEST(Yaml, no_double_substitution) unsetenv("ENV_NAME"); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: @@ -660,7 +649,7 @@ TEST(Yaml, empty_double_substitution) setenv("ENV_NAME", "", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: @@ -687,7 +676,7 @@ TEST(Yaml, with_double_substitution) setenv("ENV_NAME", "3.14", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: @@ -714,7 +703,7 @@ TEST(Yaml, with_illegal_double_substitution) setenv("ENV_NAME", "something else", 1); std::string yaml = R"( -file_format: 1.0.0 +file_format: "1.0" tracer_provider: processors: - simple: diff --git a/sdk/test/configuration/yaml_trace_test.cc b/sdk/test/configuration/yaml_trace_test.cc index 5438874052..3cbc7294a2 100644 --- a/sdk/test/configuration/yaml_trace_test.cc +++ b/sdk/test/configuration/yaml_trace_test.cc @@ -34,7 +34,7 @@ static std::unique_ptr DoParse TEST(YamlTrace, no_processors) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: )"; @@ -45,7 +45,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, empty_processors) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: )"; @@ -57,7 +57,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, many_processors) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -77,7 +77,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, simple_processor) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -102,7 +102,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_batch_processor) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - batch: @@ -131,7 +131,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, batch_processor) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - batch: @@ -164,7 +164,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_otlp_http) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -202,7 +202,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, otlp_http) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -255,7 +255,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -293,7 +293,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, otlp_grpc) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -346,7 +346,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_otlp_file) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -375,7 +375,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, otlp_file) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -405,7 +405,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, otlp_console) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -430,7 +430,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_otlp_zipkin) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -461,7 +461,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, otlp_zipkin) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -493,7 +493,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, no_limits) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -510,7 +510,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_limits) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -534,7 +534,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, limits) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -564,7 +564,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, no_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -581,7 +581,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, empty_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -597,7 +597,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, many_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -615,7 +615,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, always_off_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -634,7 +634,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, always_on_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -653,7 +653,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, jaeger_remote_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -683,7 +683,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_parent_based_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -711,7 +711,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, parent_based_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -749,7 +749,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, default_trace_id_ratio_based_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: @@ -773,7 +773,7 @@ file_format: 1.0.0-trace TEST(YamlTrace, trace_id_ratio_based_sampler) { std::string yaml = R"( -file_format: 1.0.0-trace +file_format: "1.0-trace" tracer_provider: processors: - simple: From 73e60c460d0896a26defd731344b399905e5d9fe Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 26 Sep 2025 23:43:11 +0200 Subject: [PATCH 3/4] Code review comments, make parser methods const. --- .../sdk/configuration/configuration_parser.h | 155 ++++++++-------- sdk/src/configuration/configuration_parser.cc | 172 ++++++++++-------- 2 files changed, 170 insertions(+), 157 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h index b8b682e332..fbf0db5edd 100644 --- a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h +++ b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h @@ -99,248 +99,249 @@ namespace configuration class ConfigurationParser { public: - OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name); + OtlpHttpEncoding ParseOtlpHttpEncoding(const std::string &name) const; std::unique_ptr ParseStringArrayConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseIncludeExcludeConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseHeadersConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseAttributeLimitsConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr - ParseOtlpHttpLogRecordExporterConfiguration(const std::unique_ptr &node); + ParseOtlpHttpLogRecordExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseOtlpGrpcLogRecordExporterConfiguration(const std::unique_ptr &node); + ParseOtlpGrpcLogRecordExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseOtlpFileLogRecordExporterConfiguration(const std::unique_ptr &node); + ParseOtlpFileLogRecordExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr ParseConsoleLogRecordExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseExtensionLogRecordExporterConfiguration(const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParseLogRecordExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseBatchLogRecordProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseSimpleLogRecordProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseExtensionLogRecordProcessorConfiguration(const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParseLogRecordProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseLogRecordLimitsConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseLoggerProviderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; - DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name); + DefaultHistogramAggregation ParseDefaultHistogramAggregation(const std::string &name) const; - TemporalityPreference ParseTemporalityPreference(const std::string &name); + TemporalityPreference ParseTemporalityPreference(const std::string &name) const; std::unique_ptr - ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr &node); + ParseOtlpHttpPushMetricExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseOtlpGrpcPushMetricExporterConfiguration(const std::unique_ptr &node); + ParseOtlpGrpcPushMetricExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseOtlpFilePushMetricExporterConfiguration(const std::unique_ptr &node); + ParseOtlpFilePushMetricExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseConsolePushMetricExporterConfiguration(const std::unique_ptr &node); + ParseConsolePushMetricExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParsePrometheusPullMetricExporterConfiguration(const std::unique_ptr &node); + ParsePrometheusPullMetricExporterConfiguration(const std::unique_ptr &node) const; std::unique_ptr ParsePushMetricExporterExtensionConfiguration(const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParsePullMetricExporterExtensionConfiguration(const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParsePushMetricExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParsePullMetricExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseOpenCensusMetricProducerConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseExtensionMetricProducerConfiguration( const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParseMetricProducerConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParsePeriodicMetricReaderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParsePullMetricReaderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseMetricReaderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; - InstrumentType ParseInstrumentType(const std::string &name); + InstrumentType ParseInstrumentType(const std::string &name) const; std::unique_ptr ParseViewSelectorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseDefaultAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseDropAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr - ParseExplicitBucketHistogramAggregationConfiguration(const std::unique_ptr &node); + ParseExplicitBucketHistogramAggregationConfiguration( + const std::unique_ptr &node) const; std::unique_ptr ParseBase2ExponentialBucketHistogramAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseLastValueAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseSumAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseAggregationConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseViewStreamConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseViewConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseMeterProviderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParsePropagatorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseSpanLimitsConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseAlwaysOffSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseAlwaysOnSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseJaegerRemoteSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseParentBasedSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseTraceIdRatioBasedSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseSamplerExtensionConfiguration( const std::string &name, std::unique_ptr node, - size_t depth); + size_t depth) const; std::unique_ptr ParseSamplerConfiguration( const std::unique_ptr &node, - size_t depth); + size_t depth) const; std::unique_ptr ParseOtlpHttpSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseOtlpGrpcSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseOtlpFileSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseConsoleSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseZipkinSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseExtensionSpanExporterConfiguration( const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParseSpanExporterConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseBatchSpanProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseSimpleSpanProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseExtensionSpanProcessorConfiguration( const std::string &name, - std::unique_ptr node); + std::unique_ptr node) const; std::unique_ptr ParseSpanProcessorConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseTracerProviderConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseStringAttributeValueConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseIntegerAttributeValueConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseDoubleAttributeValueConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseBooleanAttributeValueConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr - ParseStringArrayAttributeValueConfiguration(const std::unique_ptr &node); + ParseStringArrayAttributeValueConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseIntegerArrayAttributeValueConfiguration(const std::unique_ptr &node); + ParseIntegerArrayAttributeValueConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseDoubleArrayAttributeValueConfiguration(const std::unique_ptr &node); + ParseDoubleArrayAttributeValueConfiguration(const std::unique_ptr &node) const; std::unique_ptr - ParseBooleanArrayAttributeValueConfiguration(const std::unique_ptr &node); + ParseBooleanArrayAttributeValueConfiguration(const std::unique_ptr &node) const; std::unique_ptr ParseAttributesConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr ParseResourceConfiguration( - const std::unique_ptr &node); + const std::unique_ptr &node) const; std::unique_ptr Parse(std::unique_ptr doc); diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index 83768a3354..ef1b16d13f 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -105,7 +105,7 @@ namespace configuration // FIXME: proper sizing constexpr size_t MAX_SAMPLER_DEPTH = 10; -OtlpHttpEncoding ConfigurationParser::ParseOtlpHttpEncoding(const std::string &name) +OtlpHttpEncoding ConfigurationParser::ParseOtlpHttpEncoding(const std::string &name) const { if (name == "protobuf") { @@ -123,7 +123,7 @@ OtlpHttpEncoding ConfigurationParser::ParseOtlpHttpEncoding(const std::string &n } std::unique_ptr ConfigurationParser::ParseStringArrayConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -140,7 +140,7 @@ std::unique_ptr ConfigurationParser::ParseStringArrayC } std::unique_ptr ConfigurationParser::ParseIncludeExcludeConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -161,7 +161,7 @@ std::unique_ptr ConfigurationParser::ParseIncludeEx } std::unique_ptr ConfigurationParser::ParseHeadersConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr kv_pair; @@ -189,7 +189,8 @@ std::unique_ptr ConfigurationParser::ParseHeadersConfigura } std::unique_ptr -ConfigurationParser::ParseAttributeLimitsConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseAttributeLimitsConfiguration( + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -201,7 +202,7 @@ ConfigurationParser::ParseAttributeLimitsConfiguration(const std::unique_ptr ConfigurationParser::ParseOtlpHttpLogRecordExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -229,7 +230,7 @@ ConfigurationParser::ParseOtlpHttpLogRecordExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpGrpcLogRecordExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -255,7 +256,7 @@ ConfigurationParser::ParseOtlpGrpcLogRecordExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpFileLogRecordExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -267,7 +268,7 @@ ConfigurationParser::ParseOtlpFileLogRecordExporterConfiguration( std::unique_ptr ConfigurationParser::ParseConsoleLogRecordExporterConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -277,7 +278,7 @@ ConfigurationParser::ParseConsoleLogRecordExporterConfiguration( std::unique_ptr ConfigurationParser::ParseExtensionLogRecordExporterConfiguration( const std::string &name, - std::unique_ptr node) + std::unique_ptr node) const { auto model = std::make_unique(); @@ -288,7 +289,8 @@ ConfigurationParser::ParseExtensionLogRecordExporterConfiguration( } std::unique_ptr -ConfigurationParser::ParseLogRecordExporterConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseLogRecordExporterConfiguration( + const std::unique_ptr &node) const { std::unique_ptr model; @@ -336,7 +338,7 @@ ConfigurationParser::ParseLogRecordExporterConfiguration(const std::unique_ptr ConfigurationParser::ParseBatchLogRecordProcessorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -354,7 +356,7 @@ ConfigurationParser::ParseBatchLogRecordProcessorConfiguration( std::unique_ptr ConfigurationParser::ParseSimpleLogRecordProcessorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -368,7 +370,7 @@ ConfigurationParser::ParseSimpleLogRecordProcessorConfiguration( std::unique_ptr ConfigurationParser::ParseExtensionLogRecordProcessorConfiguration( const std::string &name, - std::unique_ptr node) + std::unique_ptr node) const { auto model = std::make_unique(); @@ -379,7 +381,8 @@ ConfigurationParser::ParseExtensionLogRecordProcessorConfiguration( } std::unique_ptr -ConfigurationParser::ParseLogRecordProcessorConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseLogRecordProcessorConfiguration( + const std::unique_ptr &node) const { std::unique_ptr model; @@ -418,7 +421,8 @@ ConfigurationParser::ParseLogRecordProcessorConfiguration(const std::unique_ptr< } std::unique_ptr -ConfigurationParser::ParseLogRecordLimitsConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseLogRecordLimitsConfiguration( + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -429,7 +433,7 @@ ConfigurationParser::ParseLogRecordLimitsConfiguration(const std::unique_ptr ConfigurationParser::ParseLoggerProviderConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -458,7 +462,7 @@ std::unique_ptr ConfigurationParser::ParseLoggerPro } DefaultHistogramAggregation ConfigurationParser::ParseDefaultHistogramAggregation( - const std::string &name) + const std::string &name) const { if (name == "explicit_bucket_histogram") { @@ -475,7 +479,7 @@ DefaultHistogramAggregation ConfigurationParser::ParseDefaultHistogramAggregatio throw InvalidSchemaException(message); } -TemporalityPreference ConfigurationParser::ParseTemporalityPreference(const std::string &name) +TemporalityPreference ConfigurationParser::ParseTemporalityPreference(const std::string &name) const { if (name == "cumulative") { @@ -499,7 +503,7 @@ TemporalityPreference ConfigurationParser::ParseTemporalityPreference(const std: std::unique_ptr ConfigurationParser::ParseOtlpHttpPushMetricExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -535,7 +539,7 @@ ConfigurationParser::ParseOtlpHttpPushMetricExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpGrpcPushMetricExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -570,7 +574,7 @@ ConfigurationParser::ParseOtlpGrpcPushMetricExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpFilePushMetricExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -590,7 +594,7 @@ ConfigurationParser::ParseOtlpFilePushMetricExporterConfiguration( std::unique_ptr ConfigurationParser::ParseConsolePushMetricExporterConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -601,7 +605,7 @@ ConfigurationParser::ParseConsolePushMetricExporterConfiguration( std::unique_ptr ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -617,7 +621,7 @@ ConfigurationParser::ParsePrometheusPullMetricExporterConfiguration( std::unique_ptr ConfigurationParser::ParsePushMetricExporterExtensionConfiguration( const std::string &name, - std::unique_ptr node) + std::unique_ptr node) const { auto model = std::make_unique(); @@ -630,7 +634,7 @@ ConfigurationParser::ParsePushMetricExporterExtensionConfiguration( std::unique_ptr ConfigurationParser::ParsePullMetricExporterExtensionConfiguration( const std::string &name, - std::unique_ptr node) + std::unique_ptr node) const { auto model = std::make_unique(); @@ -641,7 +645,8 @@ ConfigurationParser::ParsePullMetricExporterExtensionConfiguration( } std::unique_ptr -ConfigurationParser::ParsePushMetricExporterConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParsePushMetricExporterConfiguration( + const std::unique_ptr &node) const { std::unique_ptr model; @@ -688,7 +693,8 @@ ConfigurationParser::ParsePushMetricExporterConfiguration(const std::unique_ptr< } std::unique_ptr -ConfigurationParser::ParsePullMetricExporterConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParsePullMetricExporterConfiguration( + const std::unique_ptr &node) const { std::unique_ptr model; @@ -724,7 +730,7 @@ ConfigurationParser::ParsePullMetricExporterConfiguration(const std::unique_ptr< std::unique_ptr ConfigurationParser::ParseOpenCensusMetricProducerConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -732,8 +738,9 @@ ConfigurationParser::ParseOpenCensusMetricProducerConfiguration( } std::unique_ptr -ConfigurationParser::ParseExtensionMetricProducerConfiguration(const std::string &name, - std::unique_ptr node) +ConfigurationParser::ParseExtensionMetricProducerConfiguration( + const std::string &name, + std::unique_ptr node) const { auto model = std::make_unique(); @@ -744,7 +751,7 @@ ConfigurationParser::ParseExtensionMetricProducerConfiguration(const std::string } std::unique_ptr ConfigurationParser::ParseMetricProducerConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { std::unique_ptr model; @@ -780,7 +787,7 @@ std::unique_ptr ConfigurationParser::ParseMetricPro std::unique_ptr ConfigurationParser::ParsePeriodicMetricReaderConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -805,7 +812,8 @@ ConfigurationParser::ParsePeriodicMetricReaderConfiguration( } std::unique_ptr -ConfigurationParser::ParsePullMetricReaderConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParsePullMetricReaderConfiguration( + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -827,7 +835,7 @@ ConfigurationParser::ParsePullMetricReaderConfiguration(const std::unique_ptr ConfigurationParser::ParseMetricReaderConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { std::unique_ptr model; @@ -867,7 +875,7 @@ std::unique_ptr ConfigurationParser::ParseMetricReade return model; } -InstrumentType ConfigurationParser::ParseInstrumentType(const std::string &name) +InstrumentType ConfigurationParser::ParseInstrumentType(const std::string &name) const { if (name == "") { @@ -910,7 +918,7 @@ InstrumentType ConfigurationParser::ParseInstrumentType(const std::string &name) } std::unique_ptr ConfigurationParser::ParseViewSelectorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -929,7 +937,7 @@ std::unique_ptr ConfigurationParser::ParseViewSelecto std::unique_ptr ConfigurationParser::ParseDefaultAggregationConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -938,7 +946,7 @@ ConfigurationParser::ParseDefaultAggregationConfiguration( std::unique_ptr ConfigurationParser::ParseDropAggregationConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -947,7 +955,7 @@ ConfigurationParser::ParseDropAggregationConfiguration( std::unique_ptr ConfigurationParser::ParseExplicitBucketHistogramAggregationConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -973,7 +981,7 @@ ConfigurationParser::ParseExplicitBucketHistogramAggregationConfiguration( std::unique_ptr ConfigurationParser::ParseBase2ExponentialBucketHistogramAggregationConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -986,7 +994,7 @@ ConfigurationParser::ParseBase2ExponentialBucketHistogramAggregationConfiguratio std::unique_ptr ConfigurationParser::ParseLastValueAggregationConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -994,7 +1002,7 @@ ConfigurationParser::ParseLastValueAggregationConfiguration( } std::unique_ptr ConfigurationParser::ParseSumAggregationConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -1002,7 +1010,7 @@ std::unique_ptr ConfigurationParser::ParseSumAggreg } std::unique_ptr ConfigurationParser::ParseAggregationConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { std::unique_ptr model; std::unique_ptr child; @@ -1054,7 +1062,7 @@ std::unique_ptr ConfigurationParser::ParseAggregationC } std::unique_ptr ConfigurationParser::ParseViewStreamConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1079,7 +1087,7 @@ std::unique_ptr ConfigurationParser::ParseViewStreamCon } std::unique_ptr ConfigurationParser::ParseViewConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1094,7 +1102,7 @@ std::unique_ptr ConfigurationParser::ParseViewConfiguration( } std::unique_ptr ConfigurationParser::ParseMeterProviderConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1126,7 +1134,7 @@ std::unique_ptr ConfigurationParser::ParseMeterProvi } std::unique_ptr ConfigurationParser::ParsePropagatorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1170,7 +1178,7 @@ std::unique_ptr ConfigurationParser::ParsePropagatorCon } std::unique_ptr ConfigurationParser::ParseSpanLimitsConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1187,7 +1195,7 @@ std::unique_ptr ConfigurationParser::ParseSpanLimitsCon std::unique_ptr ConfigurationParser::ParseAlwaysOffSamplerConfiguration( const std::unique_ptr & /* node */, - size_t /* depth */) + size_t /* depth */) const { auto model = std::make_unique(); @@ -1197,7 +1205,7 @@ ConfigurationParser::ParseAlwaysOffSamplerConfiguration( std::unique_ptr ConfigurationParser::ParseAlwaysOnSamplerConfiguration( const std::unique_ptr & /* node */, - size_t /* depth */) + size_t /* depth */) const { auto model = std::make_unique(); @@ -1208,7 +1216,7 @@ ConfigurationParser::ParseAlwaysOnSamplerConfiguration( std::unique_ptr ConfigurationParser::ParseJaegerRemoteSamplerConfiguration( const std::unique_ptr &node, - size_t depth) + size_t depth) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1233,7 +1241,7 @@ ConfigurationParser::ParseJaegerRemoteSamplerConfiguration( // NOLINTBEGIN(misc-no-recursion) std::unique_ptr ConfigurationParser::ParseParentBasedSamplerConfiguration(const std::unique_ptr &node, - size_t depth) + size_t depth) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1275,7 +1283,7 @@ ConfigurationParser::ParseParentBasedSamplerConfiguration(const std::unique_ptr< std::unique_ptr ConfigurationParser::ParseTraceIdRatioBasedSamplerConfiguration( const std::unique_ptr &node, - size_t /* depth */) + size_t /* depth */) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1288,7 +1296,7 @@ ConfigurationParser::ParseTraceIdRatioBasedSamplerConfiguration( std::unique_ptr ConfigurationParser::ParseSamplerExtensionConfiguration(const std::string &name, std::unique_ptr node, - size_t depth) + size_t depth) const { auto model = std::make_unique(); @@ -1302,7 +1310,7 @@ ConfigurationParser::ParseSamplerExtensionConfiguration(const std::string &name, // NOLINTBEGIN(misc-no-recursion) std::unique_ptr ConfigurationParser::ParseSamplerConfiguration( const std::unique_ptr &node, - size_t depth) + size_t depth) const { /* * ParseSamplerConfiguration() is recursive, @@ -1367,7 +1375,7 @@ std::unique_ptr ConfigurationParser::ParseSamplerConfigura std::unique_ptr ConfigurationParser::ParseOtlpHttpSpanExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1395,7 +1403,7 @@ ConfigurationParser::ParseOtlpHttpSpanExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpGrpcSpanExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1421,7 +1429,7 @@ ConfigurationParser::ParseOtlpGrpcSpanExporterConfiguration( std::unique_ptr ConfigurationParser::ParseOtlpFileSpanExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1433,7 +1441,7 @@ ConfigurationParser::ParseOtlpFileSpanExporterConfiguration( std::unique_ptr ConfigurationParser::ParseConsoleSpanExporterConfiguration( - const std::unique_ptr & /* node */) + const std::unique_ptr & /* node */) const { auto model = std::make_unique(); @@ -1441,7 +1449,8 @@ ConfigurationParser::ParseConsoleSpanExporterConfiguration( } std::unique_ptr -ConfigurationParser::ParseZipkinSpanExporterConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseZipkinSpanExporterConfiguration( + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1452,8 +1461,9 @@ ConfigurationParser::ParseZipkinSpanExporterConfiguration(const std::unique_ptr< } std::unique_ptr -ConfigurationParser::ParseExtensionSpanExporterConfiguration(const std::string &name, - std::unique_ptr node) +ConfigurationParser::ParseExtensionSpanExporterConfiguration( + const std::string &name, + std::unique_ptr node) const { auto model = std::make_unique(); @@ -1464,7 +1474,7 @@ ConfigurationParser::ParseExtensionSpanExporterConfiguration(const std::string & } std::unique_ptr ConfigurationParser::ParseSpanExporterConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { std::unique_ptr model; @@ -1515,7 +1525,8 @@ std::unique_ptr ConfigurationParser::ParseSpanExporte } std::unique_ptr -ConfigurationParser::ParseBatchSpanProcessorConfiguration(const std::unique_ptr &node) +ConfigurationParser::ParseBatchSpanProcessorConfiguration( + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1533,7 +1544,7 @@ ConfigurationParser::ParseBatchSpanProcessorConfiguration(const std::unique_ptr< std::unique_ptr ConfigurationParser::ParseSimpleSpanProcessorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1545,8 +1556,9 @@ ConfigurationParser::ParseSimpleSpanProcessorConfiguration( } std::unique_ptr -ConfigurationParser::ParseExtensionSpanProcessorConfiguration(const std::string &name, - std::unique_ptr node) +ConfigurationParser::ParseExtensionSpanProcessorConfiguration( + const std::string &name, + std::unique_ptr node) const { auto model = std::make_unique(); @@ -1557,7 +1569,7 @@ ConfigurationParser::ParseExtensionSpanProcessorConfiguration(const std::string } std::unique_ptr ConfigurationParser::ParseSpanProcessorConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { std::unique_ptr model; @@ -1596,7 +1608,7 @@ std::unique_ptr ConfigurationParser::ParseSpanProces } std::unique_ptr ConfigurationParser::ParseTracerProviderConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1632,7 +1644,7 @@ std::unique_ptr ConfigurationParser::ParseTracerPro std::unique_ptr ConfigurationParser::ParseStringAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1643,7 +1655,7 @@ ConfigurationParser::ParseStringAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseIntegerAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1654,7 +1666,7 @@ ConfigurationParser::ParseIntegerAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseDoubleAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1665,7 +1677,7 @@ ConfigurationParser::ParseDoubleAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseBooleanAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1676,7 +1688,7 @@ ConfigurationParser::ParseBooleanAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseStringArrayAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1694,7 +1706,7 @@ ConfigurationParser::ParseStringArrayAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseIntegerArrayAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1712,7 +1724,7 @@ ConfigurationParser::ParseIntegerArrayAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseDoubleArrayAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1730,7 +1742,7 @@ ConfigurationParser::ParseDoubleArrayAttributeValueConfiguration( std::unique_ptr ConfigurationParser::ParseBooleanArrayAttributeValueConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); @@ -1747,7 +1759,7 @@ ConfigurationParser::ParseBooleanArrayAttributeValueConfiguration( } std::unique_ptr ConfigurationParser::ParseAttributesConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; @@ -1835,7 +1847,7 @@ std::unique_ptr ConfigurationParser::ParseAttributesCon } std::unique_ptr ConfigurationParser::ParseResourceConfiguration( - const std::unique_ptr &node) + const std::unique_ptr &node) const { auto model = std::make_unique(); std::unique_ptr child; From 0b29e0e506c58acc840a077de8cd4348db43eee9 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 26 Sep 2025 23:59:08 +0200 Subject: [PATCH 4/4] Resolve merge issue --- sdk/src/configuration/configuration_parser.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index ef1b16d13f..fbdd109435 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -1338,8 +1338,7 @@ std::unique_ptr ConfigurationParser::ParseSamplerConfigura if (count != 1) { - std::string message = node->Location().ToString(); - message.append(", Illegal sampler, properties count: "); + std::string message("Illegal sampler, properties count: "); message.append(std::to_string(count)); throw InvalidSchemaException(message); }