Skip to content

Commit 57253cd

Browse files
authored
[CONFIGURATION] Set schema default values for all parameters (#4432) (#4440)
1 parent 717d1fb commit 57253cd

11 files changed

Lines changed: 51 additions & 23 deletions

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ Important changes:
243243

244244
Breaking changes:
245245

246+
* [CONFIGURATION] Align declarative configuration schema defaults with
247+
OpenTelemetry Configuration Schema v1.1.0
248+
[#4432](https://github.com/open-telemetry/opentelemetry-cpp/issues/4432)
249+
* When a YAML field is omitted, the parsed configuration model now uses
250+
these schema defaults instead of the previous legacy values:
251+
* `attribute_limits.attribute_value_length_limit`,
252+
`logger_provider.limits.attribute_value_length_limit`, and
253+
`tracer_provider.limits.attribute_value_length_limit` default to no limit
254+
(unlimited attribute value length) instead of 4096 bytes.
255+
* `batch` log record processor `schedule_delay` defaults to 1000 ms instead
256+
of 5000 ms (more frequent batch exports when the field is omitted).
257+
* `periodic` metric reader `interval` defaults to 60000 ms instead of 5000 ms
258+
(less frequent metric exports when the field is omitted).
259+
* `trace_id_ratio_based` sampler `ratio` defaults to 1.0 instead of 0.0
260+
(sample all traces instead of dropping all when the field is omitted).
261+
246262
* [CONFIGURATION] SDK default component builder libraries and example
247263
[#4367](https://github.com/open-telemetry/opentelemetry-cpp/pull/4367)
248264
* The declaritive configuration registry is now empty on construction and

‎sdk/include/opentelemetry/sdk/configuration/attribute_limits_configuration.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <cstddef>
7+
#include <limits>
78

89
#include "opentelemetry/version.h"
910

@@ -18,9 +19,9 @@ namespace configuration
1819
class AttributeLimitsConfiguration
1920
{
2021
public:
21-
// TODO: spec default is no limit, using 4096 to preserve original behavior
22-
static constexpr std::size_t kDefaultAttributeValueLengthLimit = 4096;
23-
static constexpr std::size_t kDefaultAttributeCountLimit = 128;
22+
static constexpr std::size_t kDefaultAttributeValueLengthLimit =
23+
(std::numeric_limits<std::size_t>::max)();
24+
static constexpr std::size_t kDefaultAttributeCountLimit = 128;
2425

2526
std::size_t attribute_value_length_limit{kDefaultAttributeValueLengthLimit};
2627
std::size_t attribute_count_limit{kDefaultAttributeCountLimit};

‎sdk/include/opentelemetry/sdk/configuration/batch_log_record_processor_configuration.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ namespace configuration
2222
class BatchLogRecordProcessorConfiguration : public LogRecordProcessorConfiguration
2323
{
2424
public:
25-
// TODO: spec default is 1000ms for schedule_delay, using 5000ms to preserve original behavior
26-
static constexpr std::size_t kDefaultScheduleDelayMs = 5000;
25+
static constexpr std::size_t kDefaultScheduleDelayMs = 1000;
2726
static constexpr std::size_t kDefaultExportTimeoutMs = 30000;
2827
static constexpr std::size_t kDefaultMaxQueueSize = 2048;
2928
static constexpr std::size_t kDefaultMaxExportBatchSize = 512;

‎sdk/include/opentelemetry/sdk/configuration/log_record_limits_configuration.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <cstddef>
7+
#include <limits>
78

89
#include "opentelemetry/version.h"
910

@@ -18,9 +19,9 @@ namespace configuration
1819
class LogRecordLimitsConfiguration
1920
{
2021
public:
21-
// TODO: spec default is no limit, using 4096 to preserve original behavior
22-
static constexpr std::size_t kDefaultAttributeValueLengthLimit = 4096;
23-
static constexpr std::size_t kDefaultAttributeCountLimit = 128;
22+
static constexpr std::size_t kDefaultAttributeValueLengthLimit =
23+
(std::numeric_limits<std::size_t>::max)();
24+
static constexpr std::size_t kDefaultAttributeCountLimit = 128;
2425

2526
std::size_t attribute_value_length_limit{kDefaultAttributeValueLengthLimit};
2627
std::size_t attribute_count_limit{kDefaultAttributeCountLimit};

‎sdk/include/opentelemetry/sdk/configuration/periodic_metric_reader_configuration.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ namespace configuration
2525
class PeriodicMetricReaderConfiguration : public MetricReaderConfiguration
2626
{
2727
public:
28-
// TODO: spec default is 60000ms for interval, using 5000ms to preserve original behavior
29-
static constexpr std::size_t kDefaultIntervalMs = 5000;
28+
static constexpr std::size_t kDefaultIntervalMs = 60000;
3029
static constexpr std::size_t kDefaultTimeoutMs = 30000;
3130

3231
void Accept(MetricReaderConfigurationVisitor *visitor) const override

‎sdk/include/opentelemetry/sdk/configuration/span_limits_configuration.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <cstddef>
7+
#include <limits>
78

89
#include "opentelemetry/version.h"
910

@@ -18,8 +19,8 @@ namespace configuration
1819
class SpanLimitsConfiguration
1920
{
2021
public:
21-
// TODO: spec default is no limit, using 4096 to preserve original behavior
22-
static constexpr std::size_t kDefaultAttributeValueLengthLimit = 4096;
22+
static constexpr std::size_t kDefaultAttributeValueLengthLimit =
23+
(std::numeric_limits<std::size_t>::max)();
2324
static constexpr std::uint32_t kDefaultAttributeCountLimit = 128;
2425
static constexpr std::uint32_t kDefaultEventCountLimit = 128;
2526
static constexpr std::uint32_t kDefaultLinkCountLimit = 128;

‎sdk/include/opentelemetry/sdk/configuration/trace_id_ratio_based_sampler_configuration.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ namespace configuration
1818
class TraceIdRatioBasedSamplerConfiguration : public SamplerConfiguration
1919
{
2020
public:
21-
// TODO: spec default is 1.0, using 0.0 to preserve original behavior
22-
static constexpr double kDefaultRatio = 0.0;
21+
static constexpr double kDefaultRatio = 1.0;
2322

2423
void Accept(SamplerConfigurationVisitor *visitor) const override
2524
{

‎sdk/test/configuration/yaml_logs_test.cc‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ file_format: "1.1-logs"
120120
auto *batch =
121121
reinterpret_cast<opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration *>(
122122
processor);
123-
ASSERT_EQ(batch->schedule_delay, 5000);
123+
const auto defaults = opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration{};
124+
ASSERT_EQ(batch->schedule_delay, defaults.schedule_delay);
124125
ASSERT_EQ(batch->export_timeout, 30000);
125126
ASSERT_EQ(batch->max_queue_size, 2048);
126127
ASSERT_EQ(batch->max_export_batch_size, 512);
@@ -460,7 +461,9 @@ file_format: "1.0-logs"
460461
ASSERT_NE(config, nullptr);
461462
ASSERT_NE(config->logger_provider, nullptr);
462463
ASSERT_NE(config->logger_provider->limits, nullptr);
463-
ASSERT_EQ(config->logger_provider->limits->attribute_value_length_limit, 4096);
464+
const auto defaults = opentelemetry::sdk::configuration::LogRecordLimitsConfiguration{};
465+
ASSERT_EQ(config->logger_provider->limits->attribute_value_length_limit,
466+
defaults.attribute_value_length_limit);
464467
ASSERT_EQ(config->logger_provider->limits->attribute_count_limit, 128);
465468
}
466469

‎sdk/test/configuration/yaml_metrics_test.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ file_format: "1.0-metrics"
114114
auto *periodic =
115115
reinterpret_cast<opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration *>(
116116
reader);
117-
ASSERT_EQ(periodic->interval, 5000);
117+
const auto defaults = opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration{};
118+
ASSERT_EQ(periodic->interval, defaults.interval);
118119
ASSERT_EQ(periodic->timeout, 30000);
119120
ASSERT_NE(periodic->exporter, nullptr);
120121
auto *exporter = periodic->exporter.get();

‎sdk/test/configuration/yaml_test.cc‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ file_format: "1.0"
176176
ASSERT_NE(config, nullptr);
177177
ASSERT_EQ(config->file_format, "1.0");
178178
ASSERT_NE(config->attribute_limits, nullptr);
179-
ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 4096);
179+
const auto defaults = opentelemetry::sdk::configuration::AttributeLimitsConfiguration{};
180+
ASSERT_EQ(config->attribute_limits->attribute_value_length_limit,
181+
defaults.attribute_value_length_limit);
180182
ASSERT_EQ(config->attribute_limits->attribute_count_limit, 128);
181183
}
182184

@@ -608,7 +610,8 @@ file_format: "1.0"
608610
auto ratio_sampler =
609611
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
610612
sampler);
611-
ASSERT_EQ(ratio_sampler->ratio, 0.0);
613+
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
614+
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
612615
}
613616

614617
TEST(Yaml, illegal_double)
@@ -653,7 +656,8 @@ file_format: "1.0"
653656
auto ratio_sampler =
654657
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
655658
sampler);
656-
ASSERT_EQ(ratio_sampler->ratio, 0.0);
659+
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
660+
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
657661
}
658662

659663
TEST(Yaml, empty_double_substitution)
@@ -680,7 +684,8 @@ file_format: "1.0"
680684
auto ratio_sampler =
681685
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
682686
sampler);
683-
ASSERT_EQ(ratio_sampler->ratio, 0.0);
687+
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
688+
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
684689
}
685690

686691
TEST(Yaml, with_double_substitution)

0 commit comments

Comments
 (0)