Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ Important changes:

Breaking changes:

* [CONFIGURATION] Align declarative configuration schema defaults with
OpenTelemetry Configuration Schema v1.1.0
[#4432](https://github.com/open-telemetry/opentelemetry-cpp/issues/4432)
* When a YAML field is omitted, the parsed configuration model now uses
these schema defaults instead of the previous legacy values:
* `attribute_limits.attribute_value_length_limit`,
`logger_provider.limits.attribute_value_length_limit`, and
`tracer_provider.limits.attribute_value_length_limit` default to no limit
(unlimited attribute value length) instead of 4096 bytes.
* `batch` log record processor `schedule_delay` defaults to 1000 ms instead
of 5000 ms (more frequent batch exports when the field is omitted).
* `periodic` metric reader `interval` defaults to 60000 ms instead of 5000 ms
(less frequent metric exports when the field is omitted).
* `trace_id_ratio_based` sampler `ratio` defaults to 1.0 instead of 0.0
(sample all traces instead of dropping all when the field is omitted).

* [CONFIGURATION] SDK default component builder libraries and example
[#4367](https://github.com/open-telemetry/opentelemetry-cpp/pull/4367)
* The declaritive configuration registry is now empty on construction and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <cstddef>
#include <limits>

#include "opentelemetry/version.h"

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

std::size_t attribute_value_length_limit{kDefaultAttributeValueLengthLimit};
std::size_t attribute_count_limit{kDefaultAttributeCountLimit};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace configuration
class BatchLogRecordProcessorConfiguration : public LogRecordProcessorConfiguration
{
public:
// TODO: spec default is 1000ms for schedule_delay, using 5000ms to preserve original behavior
static constexpr std::size_t kDefaultScheduleDelayMs = 5000;
static constexpr std::size_t kDefaultScheduleDelayMs = 1000;
static constexpr std::size_t kDefaultExportTimeoutMs = 30000;
static constexpr std::size_t kDefaultMaxQueueSize = 2048;
static constexpr std::size_t kDefaultMaxExportBatchSize = 512;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <cstddef>
#include <limits>

#include "opentelemetry/version.h"

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

std::size_t attribute_value_length_limit{kDefaultAttributeValueLengthLimit};
std::size_t attribute_count_limit{kDefaultAttributeCountLimit};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ namespace configuration
class PeriodicMetricReaderConfiguration : public MetricReaderConfiguration
{
public:
// TODO: spec default is 60000ms for interval, using 5000ms to preserve original behavior
static constexpr std::size_t kDefaultIntervalMs = 5000;
static constexpr std::size_t kDefaultIntervalMs = 60000;
static constexpr std::size_t kDefaultTimeoutMs = 30000;

void Accept(MetricReaderConfigurationVisitor *visitor) const override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include <cstddef>
#include <limits>

#include "opentelemetry/version.h"

Expand All @@ -18,8 +19,8 @@ namespace configuration
class SpanLimitsConfiguration
{
public:
// TODO: spec default is no limit, using 4096 to preserve original behavior
static constexpr std::size_t kDefaultAttributeValueLengthLimit = 4096;
static constexpr std::size_t kDefaultAttributeValueLengthLimit =
(std::numeric_limits<std::size_t>::max)();
static constexpr std::uint32_t kDefaultAttributeCountLimit = 128;
static constexpr std::uint32_t kDefaultEventCountLimit = 128;
static constexpr std::uint32_t kDefaultLinkCountLimit = 128;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ namespace configuration
class TraceIdRatioBasedSamplerConfiguration : public SamplerConfiguration
{
public:
// TODO: spec default is 1.0, using 0.0 to preserve original behavior
static constexpr double kDefaultRatio = 0.0;
static constexpr double kDefaultRatio = 1.0;

void Accept(SamplerConfigurationVisitor *visitor) const override
{
Expand Down
7 changes: 5 additions & 2 deletions sdk/test/configuration/yaml_logs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ file_format: "1.1-logs"
auto *batch =
reinterpret_cast<opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration *>(
processor);
ASSERT_EQ(batch->schedule_delay, 5000);
const auto defaults = opentelemetry::sdk::configuration::BatchLogRecordProcessorConfiguration{};
ASSERT_EQ(batch->schedule_delay, defaults.schedule_delay);
ASSERT_EQ(batch->export_timeout, 30000);
ASSERT_EQ(batch->max_queue_size, 2048);
ASSERT_EQ(batch->max_export_batch_size, 512);
Expand Down Expand Up @@ -460,7 +461,9 @@ file_format: "1.0-logs"
ASSERT_NE(config, nullptr);
ASSERT_NE(config->logger_provider, nullptr);
ASSERT_NE(config->logger_provider->limits, nullptr);
ASSERT_EQ(config->logger_provider->limits->attribute_value_length_limit, 4096);
const auto defaults = opentelemetry::sdk::configuration::LogRecordLimitsConfiguration{};
ASSERT_EQ(config->logger_provider->limits->attribute_value_length_limit,
defaults.attribute_value_length_limit);
ASSERT_EQ(config->logger_provider->limits->attribute_count_limit, 128);
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/test/configuration/yaml_metrics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ file_format: "1.0-metrics"
auto *periodic =
reinterpret_cast<opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration *>(
reader);
ASSERT_EQ(periodic->interval, 5000);
const auto defaults = opentelemetry::sdk::configuration::PeriodicMetricReaderConfiguration{};
ASSERT_EQ(periodic->interval, defaults.interval);
ASSERT_EQ(periodic->timeout, 30000);
ASSERT_NE(periodic->exporter, nullptr);
auto *exporter = periodic->exporter.get();
Expand Down
13 changes: 9 additions & 4 deletions sdk/test/configuration/yaml_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ file_format: "1.0"
ASSERT_NE(config, nullptr);
ASSERT_EQ(config->file_format, "1.0");
ASSERT_NE(config->attribute_limits, nullptr);
ASSERT_EQ(config->attribute_limits->attribute_value_length_limit, 4096);
const auto defaults = opentelemetry::sdk::configuration::AttributeLimitsConfiguration{};
ASSERT_EQ(config->attribute_limits->attribute_value_length_limit,
defaults.attribute_value_length_limit);
ASSERT_EQ(config->attribute_limits->attribute_count_limit, 128);
}

Expand Down Expand Up @@ -608,7 +610,8 @@ file_format: "1.0"
auto ratio_sampler =
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
sampler);
ASSERT_EQ(ratio_sampler->ratio, 0.0);
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
}

TEST(Yaml, illegal_double)
Expand Down Expand Up @@ -653,7 +656,8 @@ file_format: "1.0"
auto ratio_sampler =
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
sampler);
ASSERT_EQ(ratio_sampler->ratio, 0.0);
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
}

TEST(Yaml, empty_double_substitution)
Expand All @@ -680,7 +684,8 @@ file_format: "1.0"
auto ratio_sampler =
static_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
sampler);
ASSERT_EQ(ratio_sampler->ratio, 0.0);
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
ASSERT_EQ(ratio_sampler->ratio, defaults.ratio);
}

TEST(Yaml, with_double_substitution)
Expand Down
7 changes: 5 additions & 2 deletions sdk/test/configuration/yaml_trace_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ file_format: "1.0-trace"
ASSERT_NE(config, nullptr);
ASSERT_NE(config->tracer_provider, nullptr);
ASSERT_NE(config->tracer_provider->limits, nullptr);
ASSERT_EQ(config->tracer_provider->limits->attribute_value_length_limit, 4096);
const auto defaults = opentelemetry::sdk::configuration::SpanLimitsConfiguration{};
ASSERT_EQ(config->tracer_provider->limits->attribute_value_length_limit,
defaults.attribute_value_length_limit);
ASSERT_EQ(config->tracer_provider->limits->attribute_count_limit, 128);
ASSERT_EQ(config->tracer_provider->limits->event_count_limit, 128);
ASSERT_EQ(config->tracer_provider->limits->link_count_limit, 128);
Expand Down Expand Up @@ -949,7 +951,8 @@ file_format: "1.0-trace"
auto *ratio =
reinterpret_cast<opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration *>(
sampler);
ASSERT_EQ(ratio->ratio, 0.0);
const auto defaults = opentelemetry::sdk::configuration::TraceIdRatioBasedSamplerConfiguration{};
ASSERT_EQ(ratio->ratio, defaults.ratio);
}

TEST(YamlTrace, trace_id_ratio_based_sampler)
Expand Down
Loading