From edc1f52442bc6fa195a865b2f8bac16444fb089c Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 25 Oct 2026 13:22:24 +0100 Subject: [PATCH 1/4] [CONFIGURATION] Upgrade to configuration model 1.2.0 --- .../always_record_sampler_builder.h | 38 +++++++++++ .../always_record_sampler_configuration.h | 29 ++++++++ .../sdk/configuration/configuration_parser.h | 5 ++ .../sdk/configuration/registry.h | 9 +++ .../sampler_configuration_visitor.h | 2 + sdk/src/configuration/configuration_parser.cc | 18 ++++- sdk/src/configuration/registry.cc | 6 ++ sdk/src/configuration/trace_builder_utils.cc | 22 +++++++ sdk/src/configuration/trace_builders.cc | 16 +++++ sdk/test/configuration/yaml_trace_test.cc | 66 ++++++++++++++++++- 10 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 sdk/include/opentelemetry/sdk/configuration/always_record_sampler_builder.h create mode 100644 sdk/include/opentelemetry/sdk/configuration/always_record_sampler_configuration.h diff --git a/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_builder.h b/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_builder.h new file mode 100644 index 0000000000..08cee760e4 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_builder.h @@ -0,0 +1,38 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/sdk/configuration/always_record_sampler_configuration.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace trace +{ +class Sampler; +} // namespace trace + +namespace configuration +{ + +class AlwaysRecordSamplerBuilder +{ +public: + AlwaysRecordSamplerBuilder() = default; + AlwaysRecordSamplerBuilder(AlwaysRecordSamplerBuilder &&) = default; + AlwaysRecordSamplerBuilder(const AlwaysRecordSamplerBuilder &) = default; + AlwaysRecordSamplerBuilder &operator=(AlwaysRecordSamplerBuilder &&) = default; + AlwaysRecordSamplerBuilder &operator=(const AlwaysRecordSamplerBuilder &other) = default; + virtual ~AlwaysRecordSamplerBuilder() = default; + + virtual std::unique_ptr Build( + const opentelemetry::sdk::configuration::AlwaysRecordSamplerConfiguration *model) const = 0; +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_configuration.h b/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_configuration.h new file mode 100644 index 0000000000..0a50f2f409 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/always_record_sampler_configuration.h @@ -0,0 +1,29 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "opentelemetry/sdk/configuration/sampler_configuration.h" +#include "opentelemetry/sdk/configuration/sampler_configuration_visitor.h" +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +// YAML-SCHEMA: schema/tracer_provider.json +// YAML-NODE: always_record +class AlwaysRecordSamplerConfiguration : public SamplerConfiguration +{ +public: + void Accept(SamplerConfigurationVisitor *visitor) const override + { + visitor->VisitAlwaysRecord(this); + } +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h index 14bd3218f8..1e284689d5 100644 --- a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h +++ b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h @@ -8,6 +8,7 @@ #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/always_record_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" @@ -316,6 +317,10 @@ class ConfigurationParser const std::unique_ptr &node, size_t depth) const; + std::unique_ptr ParseAlwaysRecordSamplerConfiguration( + const std::unique_ptr &node, + size_t depth) const; + std::unique_ptr ParseJaegerRemoteSamplerConfiguration( const std::unique_ptr &node, size_t depth) const; diff --git a/sdk/include/opentelemetry/sdk/configuration/registry.h b/sdk/include/opentelemetry/sdk/configuration/registry.h index 31009776f0..301cc96ffb 100644 --- a/sdk/include/opentelemetry/sdk/configuration/registry.h +++ b/sdk/include/opentelemetry/sdk/configuration/registry.h @@ -18,6 +18,7 @@ namespace configuration // Forward declarations class AlwaysOffSamplerBuilder; class AlwaysOnSamplerBuilder; +class AlwaysRecordSamplerBuilder; class BatchLogRecordProcessorBuilder; class BatchSpanProcessorBuilder; class ComposableAlwaysOffSamplerBuilder; @@ -210,6 +211,13 @@ class OPENTELEMETRY_EXPORT Registry void SetAlwaysOnSamplerBuilder(std::unique_ptr &&builder); + const AlwaysRecordSamplerBuilder *GetAlwaysRecordSamplerBuilder() const + { + return always_record_sampler_builder_.get(); + } + + void SetAlwaysRecordSamplerBuilder(std::unique_ptr &&builder); + const AlwaysOffSamplerBuilder *GetAlwaysOffSamplerBuilder() const { return always_off_sampler_builder_.get(); @@ -495,6 +503,7 @@ class OPENTELEMETRY_EXPORT Registry std::unique_ptr console_log_record_builder_; std::unique_ptr always_on_sampler_builder_; + std::unique_ptr always_record_sampler_builder_; std::unique_ptr always_off_sampler_builder_; std::unique_ptr trace_id_ratio_based_sampler_builder_; std::unique_ptr probability_sampler_builder_; diff --git a/sdk/include/opentelemetry/sdk/configuration/sampler_configuration_visitor.h b/sdk/include/opentelemetry/sdk/configuration/sampler_configuration_visitor.h index 48d8de49ba..211ef8e74d 100644 --- a/sdk/include/opentelemetry/sdk/configuration/sampler_configuration_visitor.h +++ b/sdk/include/opentelemetry/sdk/configuration/sampler_configuration_visitor.h @@ -13,6 +13,7 @@ namespace configuration class AlwaysOffSamplerConfiguration; class AlwaysOnSamplerConfiguration; +class AlwaysRecordSamplerConfiguration; class JaegerRemoteSamplerConfiguration; class ParentBasedSamplerConfiguration; class ProbabilitySamplerConfiguration; @@ -32,6 +33,7 @@ class SamplerConfigurationVisitor virtual void VisitAlwaysOff(const AlwaysOffSamplerConfiguration *model) = 0; virtual void VisitAlwaysOn(const AlwaysOnSamplerConfiguration *model) = 0; + virtual void VisitAlwaysRecord(const AlwaysRecordSamplerConfiguration *model) = 0; virtual void VisitJaegerRemote(const JaegerRemoteSamplerConfiguration *model) = 0; virtual void VisitParentBased(const ParentBasedSamplerConfiguration *model) = 0; virtual void VisitProbability(const ProbabilitySamplerConfiguration *model) = 0; diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index c0388f19fc..fe2cf44554 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -16,6 +16,7 @@ #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/always_record_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" @@ -1713,6 +1714,16 @@ ConfigurationParser::ParseAlwaysOnSamplerConfiguration( return model; } +std::unique_ptr +ConfigurationParser::ParseAlwaysRecordSamplerConfiguration( + const std::unique_ptr & /* node */, + size_t /* depth */) const +{ + auto model = std::make_unique(); + + return model; +} + // NOLINTBEGIN(misc-no-recursion) std::unique_ptr ConfigurationParser::ParseJaegerRemoteSamplerConfiguration( @@ -2109,6 +2120,11 @@ std::unique_ptr ConfigurationParser::ParseSamplerConfigura { model = ParseAlwaysOnSamplerConfiguration(child, depth); } + else if ((version_major_ == 1) && (version_minor_ >= 2) && (name == "always_record")) + { + // Added in version 1.2.0 + model = ParseAlwaysRecordSamplerConfiguration(child, depth); + } else if (name == "jaeger_remote") { model = ParseJaegerRemoteSamplerConfiguration(child, depth); @@ -2892,7 +2908,7 @@ std::unique_ptr ConfigurationParser::Parse(std::unique_ptrLocation(), message); } - if (minor > 1) + if (minor > 2) { std::string message("Unsupported file_format, major = "); message.append(std::to_string(major)); diff --git a/sdk/src/configuration/registry.cc b/sdk/src/configuration/registry.cc index 7e07531888..936110b034 100644 --- a/sdk/src/configuration/registry.cc +++ b/sdk/src/configuration/registry.cc @@ -10,6 +10,7 @@ #include "opentelemetry/context/propagation/text_map_propagator.h" #include "opentelemetry/sdk/configuration/always_off_sampler_builder.h" #include "opentelemetry/sdk/configuration/always_on_sampler_builder.h" +#include "opentelemetry/sdk/configuration/always_record_sampler_builder.h" #include "opentelemetry/sdk/configuration/batch_log_record_processor_builder.h" #include "opentelemetry/sdk/configuration/batch_span_processor_builder.h" #include "opentelemetry/sdk/configuration/composable_always_off_sampler_builder.h" @@ -235,6 +236,11 @@ void Registry::SetAlwaysOnSamplerBuilder(std::unique_ptr always_on_sampler_builder_ = std::move(builder); } +void Registry::SetAlwaysRecordSamplerBuilder(std::unique_ptr &&builder) +{ + always_record_sampler_builder_ = std::move(builder); +} + void Registry::SetAlwaysOffSamplerBuilder(std::unique_ptr &&builder) { always_off_sampler_builder_ = std::move(builder); diff --git a/sdk/src/configuration/trace_builder_utils.cc b/sdk/src/configuration/trace_builder_utils.cc index c0b7ecc338..8cbbd8e362 100644 --- a/sdk/src/configuration/trace_builder_utils.cc +++ b/sdk/src/configuration/trace_builder_utils.cc @@ -15,6 +15,8 @@ #include "opentelemetry/sdk/configuration/always_off_sampler_configuration.h" #include "opentelemetry/sdk/configuration/always_on_sampler_builder.h" #include "opentelemetry/sdk/configuration/always_on_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/always_record_sampler_builder.h" +#include "opentelemetry/sdk/configuration/always_record_sampler_configuration.h" #include "opentelemetry/sdk/configuration/batch_span_processor_builder.h" #include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h" #include "opentelemetry/sdk/configuration/composable_always_off_sampler_builder.h" @@ -287,6 +289,20 @@ static std::unique_ptr CreateAlwaysOnSampler throw UnsupportedException(message); } +static std::unique_ptr CreateAlwaysRecordSampler( + const Registry *registry, + const opentelemetry::sdk::configuration::AlwaysRecordSamplerConfiguration *model) +{ + const AlwaysRecordSamplerBuilder *builder = registry->GetAlwaysRecordSamplerBuilder(); + if (builder != nullptr) + { + OTEL_INTERNAL_LOG_DEBUG("CreateAlwaysRecordSampler() using registered builder"); + return builder->Build(model); + } + static const std::string message("No builder for AlwaysRecordSampler"); + throw UnsupportedException(message); +} + static std::unique_ptr CreateProbabilitySampler( const Registry *registry, const opentelemetry::sdk::configuration::ProbabilitySamplerConfiguration *model) @@ -461,6 +477,12 @@ class SamplerBuilder : public opentelemetry::sdk::configuration::SamplerConfigur sampler = CreateAlwaysOnSampler(registry_, model); } + void VisitAlwaysRecord( + const opentelemetry::sdk::configuration::AlwaysRecordSamplerConfiguration *model) override + { + sampler = CreateAlwaysRecordSampler(registry_, model); + } + void VisitJaegerRemote( const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration *model) override { diff --git a/sdk/src/configuration/trace_builders.cc b/sdk/src/configuration/trace_builders.cc index 694c8db498..93db63d99c 100644 --- a/sdk/src/configuration/trace_builders.cc +++ b/sdk/src/configuration/trace_builders.cc @@ -16,6 +16,7 @@ #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/configuration/always_off_sampler_builder.h" #include "opentelemetry/sdk/configuration/always_on_sampler_builder.h" +#include "opentelemetry/sdk/configuration/always_record_sampler_builder.h" #include "opentelemetry/sdk/configuration/attribute_limits_configuration.h" #include "opentelemetry/sdk/configuration/batch_span_processor_builder.h" #include "opentelemetry/sdk/configuration/batch_span_processor_configuration.h" @@ -110,6 +111,20 @@ class DefaultAlwaysOffSamplerBuilder : public AlwaysOffSamplerBuilder } }; +class DefaultAlwaysRecordSamplerBuilder : public AlwaysRecordSamplerBuilder +{ +public: + std::unique_ptr Build( + const AlwaysRecordSamplerConfiguration * /* model */) const override + { + static const std::string die("AlwaysRecordSampler not supported"); + throw UnsupportedException(die); + + // FIXME: Implement AlwaysRecordSampler in SDK + // return opentelemetry::sdk::trace::AlwaysRecordSamplerFactory::Create(); + } +}; + class DefaultTraceIdRatioBasedSamplerBuilder : public TraceIdRatioBasedSamplerBuilder { public: @@ -527,6 +542,7 @@ void RegisterDefaultTraceBuilders(Registry *registry) { registry->SetAlwaysOnSamplerBuilder(std::make_unique()); registry->SetAlwaysOffSamplerBuilder(std::make_unique()); + registry->SetAlwaysRecordSamplerBuilder(std::make_unique()); registry->SetTraceIdRatioBasedSamplerBuilder( std::make_unique()); registry->SetProbabilitySamplerBuilder(std::make_unique()); diff --git a/sdk/test/configuration/yaml_trace_test.cc b/sdk/test/configuration/yaml_trace_test.cc index 2a6f95bf44..946b8267d1 100644 --- a/sdk/test/configuration/yaml_trace_test.cc +++ b/sdk/test/configuration/yaml_trace_test.cc @@ -21,6 +21,7 @@ #include "opentelemetry/sdk/configuration/configuration.h" #include "opentelemetry/sdk/configuration/document_node.h" #include "opentelemetry/sdk/configuration/extension_composable_sampler_configuration.h" +#include "opentelemetry/sdk/configuration/extension_sampler_configuration.h" #include "opentelemetry/sdk/configuration/grpc_tls_configuration.h" #include "opentelemetry/sdk/configuration/headers_configuration.h" #include "opentelemetry/sdk/configuration/http_tls_configuration.h" @@ -66,7 +67,10 @@ enum class SamplerType : std::uint8_t kComposableAlwaysOff = 9, kComposableParentThreshold = 10, kProbability = 11, - kComposableExtension = 12 + kExtension = 12, + kComposableExtension = 13, + // Added in 1.2.0 + kAlwaysRecord = 14 }; class TestComposableSamplerVisitor @@ -137,6 +141,11 @@ class TestSamplerVisitor : public opentelemetry::sdk::configuration::SamplerConf { type_matched = SamplerType::kAlwaysOn; } + void VisitAlwaysRecord( + const opentelemetry::sdk::configuration::AlwaysRecordSamplerConfiguration *) override + { + type_matched = SamplerType::kAlwaysRecord; + } void VisitJaegerRemote( const opentelemetry::sdk::configuration::JaegerRemoteSamplerConfiguration *) override { @@ -161,8 +170,11 @@ class TestSamplerVisitor : public opentelemetry::sdk::configuration::SamplerConf ratio = model->ratio; } void VisitExtension( - const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *) override - {} + const opentelemetry::sdk::configuration::ExtensionSamplerConfiguration *model) override + { + type_matched = SamplerType::kExtension; + extension_name = model->name; + } void VisitComposite( const opentelemetry::sdk::configuration::CompositeSamplerConfiguration *model) override @@ -855,6 +867,54 @@ file_format: "1.0-trace" ASSERT_NE(config->tracer_provider->sampler, nullptr); } +TEST(YamlTrace, always_record_sampler_1_1) +{ + std::string yaml = R"( +file_format: "1.1-trace" +tracer_provider: + processors: + - simple: + exporter: + console: + sampler: + always_record: +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->tracer_provider, nullptr); + ASSERT_NE(config->tracer_provider->sampler, nullptr); + + TestSamplerVisitor visitor; + config->tracer_provider->sampler->Accept(&visitor); + // always_record not a builtin, seen as extension + EXPECT_EQ(visitor.type_matched, SamplerType::kExtension); + EXPECT_EQ(visitor.extension_name, "always_record"); +} + +TEST(YamlTrace, always_record_sampler_1_2) +{ + std::string yaml = R"( +file_format: "1.2-trace" +tracer_provider: + processors: + - simple: + exporter: + console: + sampler: + always_record: +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_NE(config->tracer_provider, nullptr); + ASSERT_NE(config->tracer_provider->sampler, nullptr); + + TestSamplerVisitor visitor; + config->tracer_provider->sampler->Accept(&visitor); + EXPECT_EQ(visitor.type_matched, SamplerType::kAlwaysRecord); +} + TEST(YamlTrace, jaeger_remote_sampler) { std::string yaml = R"( From 220e20c8b25a748f45014cbbb8aa41b88fd80441 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 25 Oct 2026 15:40:23 +0100 Subject: [PATCH 2/4] Implement meter_provider.view_matching_mode --- .../sdk/configuration/configuration_parser.h | 4 +++ .../meter_provider_configuration.h | 2 ++ .../sdk/configuration/view_matching_mode.h | 26 ++++++++++++++ sdk/src/configuration/configuration_parser.cc | 36 +++++++++++++++++++ sdk/src/configuration/metrics_builders.cc | 2 ++ sdk/test/configuration/yaml_test.cc | 14 +++++++- third_party_release | 2 +- 7 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 sdk/include/opentelemetry/sdk/configuration/view_matching_mode.h diff --git a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h index 1e284689d5..15e1748280 100644 --- a/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h +++ b/sdk/include/opentelemetry/sdk/configuration/configuration_parser.h @@ -108,6 +108,7 @@ #include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" #include "opentelemetry/sdk/configuration/translation_strategy.h" #include "opentelemetry/sdk/configuration/view_configuration.h" +#include "opentelemetry/sdk/configuration/view_matching_mode.h" #include "opentelemetry/sdk/configuration/view_selector_configuration.h" #include "opentelemetry/sdk/configuration/view_stream_configuration.h" #include "opentelemetry/version.h" @@ -259,6 +260,9 @@ class ConfigurationParser ExemplarFilter ParseExemplarFilter(const std::unique_ptr &node, const std::string &name) const; + ViewMatchingMode ParseViewMatchingMode(const std::unique_ptr &node, + const std::string &name) const; + std::unique_ptr ParseViewSelectorConfiguration( const std::unique_ptr &node) const; diff --git a/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h b/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h index 844516a5b6..b10fa19606 100644 --- a/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/meter_provider_configuration.h @@ -10,6 +10,7 @@ #include "opentelemetry/sdk/configuration/meter_configurator_configuration.h" #include "opentelemetry/sdk/configuration/metric_reader_configuration.h" #include "opentelemetry/sdk/configuration/view_configuration.h" +#include "opentelemetry/sdk/configuration/view_matching_mode.h" #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE @@ -27,6 +28,7 @@ class MeterProviderConfiguration std::vector> views; ExemplarFilter exemplar_filter{ExemplarFilter::trace_based}; std::unique_ptr meter_configurator; + ViewMatchingMode view_matching_mode{ViewMatchingMode::independent}; }; } // namespace configuration diff --git a/sdk/include/opentelemetry/sdk/configuration/view_matching_mode.h b/sdk/include/opentelemetry/sdk/configuration/view_matching_mode.h new file mode 100644 index 0000000000..5d3b1a59b7 --- /dev/null +++ b/sdk/include/opentelemetry/sdk/configuration/view_matching_mode.h @@ -0,0 +1,26 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include + +#include "opentelemetry/version.h" + +OPENTELEMETRY_BEGIN_NAMESPACE +namespace sdk +{ +namespace configuration +{ + +// YAML-SCHEMA: schema/meter_provider.yaml +// YAML-NODE: ViewMatchingMode +enum class ViewMatchingMode : std::uint8_t +{ + independent, + composable +}; + +} // namespace configuration +} // namespace sdk +OPENTELEMETRY_END_NAMESPACE diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index fe2cf44554..ed29641407 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -131,6 +131,7 @@ #include "opentelemetry/sdk/configuration/tracer_provider_configuration.h" #include "opentelemetry/sdk/configuration/translation_strategy.h" #include "opentelemetry/sdk/configuration/view_configuration.h" +#include "opentelemetry/sdk/configuration/view_matching_mode.h" #include "opentelemetry/sdk/configuration/view_selector_configuration.h" #include "opentelemetry/sdk/configuration/view_stream_configuration.h" #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" @@ -1334,6 +1335,30 @@ ExemplarFilter ConfigurationParser::ParseExemplarFilter(const std::unique_ptrLocation(), message); } +ViewMatchingMode ConfigurationParser::ParseViewMatchingMode( + const std::unique_ptr &node, + const std::string &name) const +{ + if (name == "") + { + return ViewMatchingMode::independent; + } + + if (name == "independent") + { + return ViewMatchingMode::independent; + } + + if (name == "composable") + { + return ViewMatchingMode::composable; + } + + std::string message("Illegal view matching mode: "); + message.append(name); + throw InvalidSchemaException(node->Location(), message); +} + std::unique_ptr ConfigurationParser::ParseViewSelectorConfiguration( const std::unique_ptr &node) const { @@ -1618,6 +1643,17 @@ std::unique_ptr ConfigurationParser::ParseMeterProvi model->meter_configurator = ParseMeterConfiguratorConfiguration(child); } + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + std::string view_matching_mode = + node->GetString("view_matching_mode/development", "independent"); + model->view_matching_mode = ParseViewMatchingMode(node, view_matching_mode); + } + else + { + model->view_matching_mode = ViewMatchingMode::independent; + } + return model; } diff --git a/sdk/src/configuration/metrics_builders.cc b/sdk/src/configuration/metrics_builders.cc index 7a21d53c3b..52f278e023 100644 --- a/sdk/src/configuration/metrics_builders.cc +++ b/sdk/src/configuration/metrics_builders.cc @@ -154,6 +154,8 @@ class DefaultMeterProviderBuilder : public MeterProviderBuilder auto sdk_exemplar_filter = ConvertExemplarFilter(model->exemplar_filter); #endif + // FIXME-SDK: support ViewMatchingMode + std::unique_ptr meter_context; if (model->meter_configurator) { diff --git a/sdk/test/configuration/yaml_test.cc b/sdk/test/configuration/yaml_test.cc index 647312fb8e..24efc8fbe2 100644 --- a/sdk/test/configuration/yaml_test.cc +++ b/sdk/test/configuration/yaml_test.cc @@ -88,7 +88,7 @@ file_format: "2.0" TEST(Yaml, unsupported_new_minor_format) { std::string yaml = R"( -file_format: "1.2" +file_format: "1.3" )"; auto config = DoParse(yaml); @@ -118,6 +118,18 @@ file_format: "1.1" ASSERT_EQ(config->file_format, "1.1"); } +TEST(Yaml, just_format_1_2) +{ + // 1.2.0 released 2026-09-11 + std::string yaml = R"( +file_format: "1.2" +)"; + + auto config = DoParse(yaml); + ASSERT_NE(config, nullptr); + ASSERT_EQ(config->file_format, "1.2"); +} + TEST(Yaml, disabled) { std::string yaml = R"( diff --git a/third_party_release b/third_party_release index 74a7886fa9..533bb38d03 100644 --- a/third_party_release +++ b/third_party_release @@ -22,7 +22,7 @@ benchmark=v1.9.5 googletest=v1.18.0 ms-gsl=v4.2.1 nlohmann-json=v3.12.0 -opentelemetry-configuration=v1.1.0 +opentelemetry-configuration=v1.2.0 opentelemetry-proto=v1.11.0 opentracing-cpp=v1.6.0 prometheus-cpp=v1.3.0 From ffcccc2df544951aec87849240b260796675de73 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 25 Oct 2026 17:18:47 +0100 Subject: [PATCH 3/4] Implement attribute_value_depth_limit --- .../exporters/otlp/otlp_recordable.h | 3 +- exporters/otlp/src/otlp_recordable.cc | 1 + .../attribute_limits_configuration.h | 4 ++- .../log_record_limits_configuration.h | 4 ++- .../configuration/span_limits_configuration.h | 2 ++ .../sdk/logs/log_record_limits.h | 3 ++ .../opentelemetry/sdk/trace/span_limits.h | 5 +++ sdk/src/configuration/configuration_parser.cc | 32 +++++++++++++++---- sdk/src/configuration/logs_builders.cc | 7 ++++ sdk/src/configuration/trace_builders.cc | 7 ++++ sdk/src/trace/span_limits.cc | 2 ++ 11 files changed, 60 insertions(+), 10 deletions(-) diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h index d4c30483f8..67ec63620a 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_recordable.h @@ -52,7 +52,8 @@ class OtlpRecordable final : public opentelemetry::sdk::trace::Recordable std::uint32_t max_attributes_per_event = (std::numeric_limits::max)(), std::uint32_t max_attributes_per_link = (std::numeric_limits::max)()) : span_limits_{max_attributes, - (std::numeric_limits::max)(), + (std::numeric_limits::max)(), // attribute_value_length_limit + (std::numeric_limits::max)(), // attribute_value_depth_limit max_events, max_links, max_attributes_per_event, diff --git a/exporters/otlp/src/otlp_recordable.cc b/exporters/otlp/src/otlp_recordable.cc index 00197ba5f6..38c7d0254f 100644 --- a/exporters/otlp/src/otlp_recordable.cc +++ b/exporters/otlp/src/otlp_recordable.cc @@ -124,6 +124,7 @@ void OtlpRecordable::SetSpanLimits(const opentelemetry::sdk::trace::SpanLimits & span_limits_ = { (std::min)(span_limits_.attribute_count_limit, limits.attribute_count_limit), (std::min)(span_limits_.attribute_value_length_limit, limits.attribute_value_length_limit), + (std::min)(span_limits_.attribute_value_depth_limit, limits.attribute_value_depth_limit), (std::min)(span_limits_.event_count_limit, limits.event_count_limit), (std::min)(span_limits_.link_count_limit, limits.link_count_limit), (std::min)(span_limits_.event_attribute_count_limit, limits.event_attribute_count_limit), diff --git a/sdk/include/opentelemetry/sdk/configuration/attribute_limits_configuration.h b/sdk/include/opentelemetry/sdk/configuration/attribute_limits_configuration.h index 98a0042de9..203e0d70ea 100644 --- a/sdk/include/opentelemetry/sdk/configuration/attribute_limits_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/attribute_limits_configuration.h @@ -22,9 +22,11 @@ class AttributeLimitsConfiguration public: static constexpr std::size_t kDefaultAttributeValueLengthLimit = (std::numeric_limits::max)(); - static constexpr std::size_t kDefaultAttributeCountLimit = 128; + static constexpr std::size_t kDefaultAttributeValueDepthLimit = 64; + static constexpr std::size_t kDefaultAttributeCountLimit = 128; OptionalValue attribute_value_length_limit; + OptionalValue attribute_value_depth_limit; OptionalValue attribute_count_limit; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/log_record_limits_configuration.h b/sdk/include/opentelemetry/sdk/configuration/log_record_limits_configuration.h index d7c427ae96..6e189aa241 100644 --- a/sdk/include/opentelemetry/sdk/configuration/log_record_limits_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/log_record_limits_configuration.h @@ -22,9 +22,11 @@ class LogRecordLimitsConfiguration public: static constexpr std::size_t kDefaultAttributeValueLengthLimit = (std::numeric_limits::max)(); - static constexpr std::size_t kDefaultAttributeCountLimit = 128; + static constexpr std::size_t kDefaultAttributeValueDepthLimit = 64; + static constexpr std::size_t kDefaultAttributeCountLimit = 128; OptionalValue attribute_value_length_limit; + OptionalValue attribute_value_depth_limit; OptionalValue attribute_count_limit; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h b/sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h index f6ad99290f..fba375c9c0 100644 --- a/sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h @@ -23,6 +23,7 @@ class SpanLimitsConfiguration public: static constexpr std::size_t kDefaultAttributeValueLengthLimit = (std::numeric_limits::max)(); + static constexpr std::size_t kDefaultAttributeValueDepthLimit = 64; static constexpr std::uint32_t kDefaultAttributeCountLimit = 128; static constexpr std::uint32_t kDefaultEventCountLimit = 128; static constexpr std::uint32_t kDefaultLinkCountLimit = 128; @@ -30,6 +31,7 @@ class SpanLimitsConfiguration static constexpr std::uint32_t kDefaultLinkAttributeCountLimit = 128; OptionalValue attribute_value_length_limit; + OptionalValue attribute_value_depth_limit; OptionalValue attribute_count_limit; OptionalValue event_count_limit; OptionalValue link_count_limit; diff --git a/sdk/include/opentelemetry/sdk/logs/log_record_limits.h b/sdk/include/opentelemetry/sdk/logs/log_record_limits.h index 0d16bf3ccd..2407ff13bc 100644 --- a/sdk/include/opentelemetry/sdk/logs/log_record_limits.h +++ b/sdk/include/opentelemetry/sdk/logs/log_record_limits.h @@ -27,9 +27,11 @@ struct LogRecordLimits static constexpr std::size_t kDefaultAttributeCountLimit = 128; static constexpr std::size_t kDefaultAttributeValueLengthLimit = (std::numeric_limits::max)(); + static constexpr std::size_t kDefaultAttributeValueDepthLimit = 64; std::size_t attribute_count_limit = kDefaultAttributeCountLimit; std::size_t attribute_value_length_limit = kDefaultAttributeValueLengthLimit; + std::size_t attribute_value_depth_limit = kDefaultAttributeValueDepthLimit; /** * Limits that impose no cap. A recordable uses these until a LoggerProvider @@ -39,6 +41,7 @@ struct LogRecordLimits static constexpr LogRecordLimits NoLimits() noexcept { return LogRecordLimits{(std::numeric_limits::max)(), + (std::numeric_limits::max)(), (std::numeric_limits::max)()}; } }; diff --git a/sdk/include/opentelemetry/sdk/trace/span_limits.h b/sdk/include/opentelemetry/sdk/trace/span_limits.h index bbadcedc6e..506c2537a2 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_limits.h +++ b/sdk/include/opentelemetry/sdk/trace/span_limits.h @@ -28,6 +28,7 @@ struct SpanLimits static constexpr std::uint32_t kDefaultLinkAttributeCountLimit = 128; static constexpr std::size_t kDefaultAttributeValueLengthLimit = (std::numeric_limits::max)(); + static constexpr std::size_t kDefaultAttributeValueDepthLimit = 64; /// Maximum number of attributes per span. std::uint32_t attribute_count_limit{kDefaultAttributeCountLimit}; @@ -35,6 +36,9 @@ struct SpanLimits /// Maximum allowed attribute value length (applies to string values and byte arrays) std::size_t attribute_value_length_limit{kDefaultAttributeValueLengthLimit}; + /// Maximum allowed attribute depth length + std::size_t attribute_value_depth_limit{kDefaultAttributeValueDepthLimit}; + /// Maximum number of events per span. std::uint32_t event_count_limit{kDefaultEventCountLimit}; @@ -55,6 +59,7 @@ struct SpanLimits SpanLimits limits; limits.attribute_count_limit = (std::numeric_limits::max)(); limits.attribute_value_length_limit = (std::numeric_limits::max)(); + limits.attribute_value_depth_limit = (std::numeric_limits::max)(); limits.event_count_limit = (std::numeric_limits::max)(); limits.link_count_limit = (std::numeric_limits::max)(); limits.event_attribute_count_limit = (std::numeric_limits::max)(); diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index ed29641407..469a805163 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -365,7 +365,13 @@ ConfigurationParser::ParseAttributeLimitsConfiguration( auto model = std::make_unique(); model->attribute_value_length_limit = node->GetOptionalInteger("attribute_value_length_limit"); - model->attribute_count_limit = node->GetOptionalInteger("attribute_count_limit"); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->attribute_value_depth_limit = node->GetOptionalInteger("attribute_value_depth_limit"); + } + + model->attribute_count_limit = node->GetOptionalInteger("attribute_count_limit"); return model; } @@ -642,7 +648,13 @@ ConfigurationParser::ParseLogRecordLimitsConfiguration( auto model = std::make_unique(); model->attribute_value_length_limit = node->GetOptionalInteger("attribute_value_length_limit"); - model->attribute_count_limit = node->GetOptionalInteger("attribute_count_limit"); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->attribute_value_depth_limit = node->GetOptionalInteger("attribute_value_depth_limit"); + } + + model->attribute_count_limit = node->GetOptionalInteger("attribute_count_limit"); return model; } @@ -1721,11 +1733,17 @@ std::unique_ptr ConfigurationParser::ParseSpanLimitsCon }; model->attribute_value_length_limit = node->GetOptionalInteger("attribute_value_length_limit"); - model->attribute_count_limit = get_optional_uint32("attribute_count_limit"); - model->event_count_limit = get_optional_uint32("event_count_limit"); - model->link_count_limit = get_optional_uint32("link_count_limit"); - model->event_attribute_count_limit = get_optional_uint32("event_attribute_count_limit"); - model->link_attribute_count_limit = get_optional_uint32("link_attribute_count_limit"); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->attribute_value_depth_limit = node->GetOptionalInteger("attribute_value_depth_limit"); + } + + model->attribute_count_limit = get_optional_uint32("attribute_count_limit"); + model->event_count_limit = get_optional_uint32("event_count_limit"); + model->link_count_limit = get_optional_uint32("link_count_limit"); + model->event_attribute_count_limit = get_optional_uint32("event_attribute_count_limit"); + model->link_attribute_count_limit = get_optional_uint32("link_attribute_count_limit"); return model; } diff --git a/sdk/src/configuration/logs_builders.cc b/sdk/src/configuration/logs_builders.cc index 0060df97d4..6badd430af 100644 --- a/sdk/src/configuration/logs_builders.cc +++ b/sdk/src/configuration/logs_builders.cc @@ -233,18 +233,22 @@ class DefaultLoggerProviderBuilder : public LoggerProviderBuilder opentelemetry::sdk::logs::LogRecordLimits log_record_limits; OptionalValue model_attribute_value_length_limit; + OptionalValue model_attribute_value_depth_limit; OptionalValue model_attribute_count_limit; if (model->limits) { model_attribute_value_length_limit = model->limits->attribute_value_length_limit; + model_attribute_value_depth_limit = model->limits->attribute_value_depth_limit; model_attribute_count_limit = model->limits->attribute_count_limit; } OptionalValue general_attribute_value_length_limit; + OptionalValue general_attribute_value_depth_limit; OptionalValue general_attribute_count_limit; if (context.attribute_limits) { general_attribute_value_length_limit = context.attribute_limits->attribute_value_length_limit; + general_attribute_value_depth_limit = context.attribute_limits->attribute_value_depth_limit; general_attribute_count_limit = context.attribute_limits->attribute_count_limit; } @@ -252,6 +256,9 @@ class DefaultLoggerProviderBuilder : public LoggerProviderBuilder log_record_limits.attribute_value_length_limit = ResolveLimit(model_attribute_value_length_limit, general_attribute_value_length_limit, LogLimitDefaults::kDefaultAttributeValueLengthLimit); + log_record_limits.attribute_value_depth_limit = + ResolveLimit(model_attribute_value_depth_limit, general_attribute_value_depth_limit, + LogLimitDefaults::kDefaultAttributeValueLengthLimit); log_record_limits.attribute_count_limit = ResolveLimit(model_attribute_count_limit, general_attribute_count_limit, LogLimitDefaults::kDefaultAttributeCountLimit); diff --git a/sdk/src/configuration/trace_builders.cc b/sdk/src/configuration/trace_builders.cc index 93db63d99c..785b9ab0ec 100644 --- a/sdk/src/configuration/trace_builders.cc +++ b/sdk/src/configuration/trace_builders.cc @@ -453,6 +453,7 @@ class DefaultTracerProviderBuilder : public TracerProviderBuilder opentelemetry::sdk::trace::SpanLimits span_limits; OptionalValue model_attribute_value_length_limit; + OptionalValue model_attribute_value_depth_limit; OptionalValue model_attribute_count_limit; OptionalValue model_event_count_limit; OptionalValue model_link_count_limit; @@ -461,6 +462,7 @@ class DefaultTracerProviderBuilder : public TracerProviderBuilder if (model->limits) { model_attribute_value_length_limit = model->limits->attribute_value_length_limit; + model_attribute_value_depth_limit = model->limits->attribute_value_depth_limit; model_attribute_count_limit = model->limits->attribute_count_limit; model_event_count_limit = model->limits->event_count_limit; model_link_count_limit = model->limits->link_count_limit; @@ -469,10 +471,12 @@ class DefaultTracerProviderBuilder : public TracerProviderBuilder } OptionalValue general_attribute_value_length_limit; + OptionalValue general_attribute_value_depth_limit; OptionalValue general_attribute_count_limit; if (context.attribute_limits) { general_attribute_value_length_limit = context.attribute_limits->attribute_value_length_limit; + general_attribute_value_depth_limit = context.attribute_limits->attribute_value_depth_limit; general_attribute_count_limit = context.attribute_limits->attribute_count_limit; } @@ -480,6 +484,9 @@ class DefaultTracerProviderBuilder : public TracerProviderBuilder span_limits.attribute_value_length_limit = ResolveLimit(model_attribute_value_length_limit, general_attribute_value_length_limit, SpanLimitDefaults::kDefaultAttributeValueLengthLimit); + span_limits.attribute_value_depth_limit = + ResolveLimit(model_attribute_value_depth_limit, general_attribute_value_depth_limit, + SpanLimitDefaults::kDefaultAttributeValueLengthLimit); span_limits.attribute_count_limit = ResolveLimit(model_attribute_count_limit, ToOptionalUint32(general_attribute_count_limit), SpanLimitDefaults::kDefaultAttributeCountLimit); diff --git a/sdk/src/trace/span_limits.cc b/sdk/src/trace/span_limits.cc index f0f711cd60..fd8e0df982 100644 --- a/sdk/src/trace/span_limits.cc +++ b/sdk/src/trace/span_limits.cc @@ -48,9 +48,11 @@ SpanLimits GetSpanLimitsFromEnv(const SpanLimits &defaults) // General attribute limits first; the span-specific variables below take precedence. UpdateFromEnv(kAttributeValueLengthLimitEnv, limits.attribute_value_length_limit); + // No OTEL_ATTRIBUTE_VALUE_DEPTH_LIMIT in the specification UpdateFromEnv(kAttributeCountLimitEnv, limits.attribute_count_limit); UpdateFromEnv(kSpanAttributeValueLengthLimitEnv, limits.attribute_value_length_limit); + // No OTEL_SPAN_ATTRIBUTE_VALUE_DEPTH_LIMIT in the specification UpdateFromEnv(kSpanAttributeCountLimitEnv, limits.attribute_count_limit); UpdateFromEnv(kSpanEventCountLimitEnv, limits.event_count_limit); UpdateFromEnv(kSpanLinkCountLimitEnv, limits.link_count_limit); From 6cc4b6fcc100974b5869ec8d70fa2613fc8e60c2 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Sun, 25 Oct 2026 18:22:27 +0100 Subject: [PATCH 4/4] Add max_request_size and max_response_size to OTLP exporters --- ...p_grpc_log_record_exporter_configuration.h | 4 + ..._grpc_push_metric_exporter_configuration.h | 4 + .../otlp_grpc_span_exporter_configuration.h | 4 + ...p_http_log_record_exporter_configuration.h | 4 + ..._http_push_metric_exporter_configuration.h | 4 + .../otlp_http_span_exporter_configuration.h | 4 + sdk/src/configuration/configuration_parser.cc | 84 +++++++++++++++++-- 7 files changed, 102 insertions(+), 6 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h index e1f036eb4d..7f9359c3e4 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_log_record_exporter_configuration.h @@ -25,6 +25,8 @@ class OtlpGrpcLogRecordExporterConfiguration : public LogRecordExporterConfigura { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB void Accept(LogRecordExporterConfigurationVisitor *visitor) const override { @@ -36,6 +38,8 @@ class OtlpGrpcLogRecordExporterConfiguration : public LogRecordExporterConfigura std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h index 3078042ca0..216d010a51 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_push_metric_exporter_configuration.h @@ -27,6 +27,8 @@ class OtlpGrpcPushMetricExporterConfiguration : public PushMetricExporterConfigu { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB static constexpr TemporalityPreference kDefaultTemporalityPreference = TemporalityPreference::cumulative; static constexpr DefaultHistogramAggregation kDefaultHistogramAggregation = @@ -42,6 +44,8 @@ class OtlpGrpcPushMetricExporterConfiguration : public PushMetricExporterConfigu std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; TemporalityPreference temporality_preference{kDefaultTemporalityPreference}; DefaultHistogramAggregation default_histogram_aggregation{kDefaultHistogramAggregation}; diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h index d61af2f9b1..ab5b2d0d38 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_grpc_span_exporter_configuration.h @@ -25,6 +25,8 @@ class OtlpGrpcSpanExporterConfiguration : public SpanExporterConfiguration { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB void Accept(SpanExporterConfigurationVisitor *visitor) const override { @@ -36,6 +38,8 @@ class OtlpGrpcSpanExporterConfiguration : public SpanExporterConfiguration std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h index ac008febb5..28e5ce22bc 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_http_log_record_exporter_configuration.h @@ -26,6 +26,8 @@ class OtlpHttpLogRecordExporterConfiguration : public LogRecordExporterConfigura { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB void Accept(LogRecordExporterConfigurationVisitor *visitor) const override { @@ -37,6 +39,8 @@ class OtlpHttpLogRecordExporterConfiguration : public LogRecordExporterConfigura std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; OtlpHttpEncoding encoding{OtlpHttpEncoding::protobuf}; }; diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h index a5da072812..fabbe6eb50 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_http_push_metric_exporter_configuration.h @@ -28,6 +28,8 @@ class OtlpHttpPushMetricExporterConfiguration : public PushMetricExporterConfigu { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB static constexpr TemporalityPreference kDefaultTemporalityPreference = TemporalityPreference::cumulative; static constexpr DefaultHistogramAggregation kDefaultHistogramAggregation = @@ -43,6 +45,8 @@ class OtlpHttpPushMetricExporterConfiguration : public PushMetricExporterConfigu std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; OtlpHttpEncoding encoding{OtlpHttpEncoding::protobuf}; TemporalityPreference temporality_preference{kDefaultTemporalityPreference}; diff --git a/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h b/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h index 5867db0e24..985413a9fd 100644 --- a/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h +++ b/sdk/include/opentelemetry/sdk/configuration/otlp_http_span_exporter_configuration.h @@ -26,6 +26,8 @@ class OtlpHttpSpanExporterConfiguration : public SpanExporterConfiguration { public: static constexpr std::size_t kDefaultTimeoutMs = 10000; + static constexpr std::size_t kMaxRequestSize = 64 * 1024 * 1024; // 64 MiB + static constexpr std::size_t kMaxResponseSize = 4 * 1024 * 1024; // 4 MiB void Accept(SpanExporterConfigurationVisitor *visitor) const override { @@ -37,6 +39,8 @@ class OtlpHttpSpanExporterConfiguration : public SpanExporterConfiguration std::unique_ptr headers; std::string headers_list; std::string compression; + std::size_t max_request_size{kMaxRequestSize}; + std::size_t max_response_size{kMaxResponseSize}; std::size_t timeout{kDefaultTimeoutMs}; OtlpHttpEncoding encoding{OtlpHttpEncoding::protobuf}; }; diff --git a/sdk/src/configuration/configuration_parser.cc b/sdk/src/configuration/configuration_parser.cc index 469a805163..26613b26e5 100644 --- a/sdk/src/configuration/configuration_parser.cc +++ b/sdk/src/configuration/configuration_parser.cc @@ -426,7 +426,19 @@ ConfigurationParser::ParseOtlpHttpLogRecordExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); const std::string encoding = node->GetString("encoding", "protobuf"); model->encoding = ParseOtlpHttpEncoding(node, encoding); @@ -458,7 +470,19 @@ ConfigurationParser::ParseOtlpGrpcLogRecordExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); return model; } @@ -810,7 +834,19 @@ ConfigurationParser::ParseOtlpHttpPushMetricExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); const std::string temporality_preference = node->GetString("temporality_preference", "cumulative"); @@ -851,7 +887,19 @@ ConfigurationParser::ParseOtlpGrpcPushMetricExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); const std::string temporality_preference = node->GetString("temporality_preference", "cumulative"); @@ -2234,7 +2282,19 @@ ConfigurationParser::ParseOtlpHttpSpanExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); const std::string encoding = node->GetString("encoding", "protobuf"); model->encoding = ParseOtlpHttpEncoding(node, encoding); @@ -2266,7 +2326,19 @@ ConfigurationParser::ParseOtlpGrpcSpanExporterConfiguration( model->headers_list = node->GetString("headers_list", ""); model->compression = node->GetString("compression", ""); - model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); + + if ((version_major_ == 1) && (version_minor_ >= 2)) + { + model->max_request_size = node->GetInteger("max_request_size", Config::kMaxRequestSize); + model->max_response_size = node->GetInteger("max_response_size", Config::kMaxResponseSize); + } + else + { + model->max_request_size = 0; + model->max_response_size = Config::kMaxResponseSize; + } + + model->timeout = node->GetInteger("timeout", Config::kDefaultTimeoutMs); return model; }