Skip to content

[CONFIGURATION] Apply general attribute_limits to tracer and logger providers - #4468

Open
ayush-singh-0601 wants to merge 7 commits into
open-telemetry:mainfrom
ayush-singh-0601:config-general-attribute-limits
Open

[CONFIGURATION] Apply general attribute_limits to tracer and logger providers#4468
ayush-singh-0601 wants to merge 7 commits into
open-telemetry:mainfrom
ayush-singh-0601:config-general-attribute-limits

Conversation

@ayush-singh-0601

@ayush-singh-0601 ayush-singh-0601 commented Aug 21, 2026

Copy link
Copy Markdown

Fixes #4467

The YAML parser already accepted attribute_limits, but SdkBuilder logged a warning and ignored them. Per the spec, general attribute limits should apply when tracer/logger limits are not set, and model-specific limits should win when they are.

Changes

  • Pass attribute_limits from CreateConfiguredSdk into CreateTracerProvider and CreateLoggerProvider.
  • If a provider has no limits, copy attribute_count_limit and attribute_value_length_limit from the general config into SpanLimits / LogRecordLimits.
  • If a provider does have limits, keep using those values (including span-only fields such as event/link limits).
  • CreateTracerProvider and CreateLoggerProvider take an optional AttributeLimitsConfiguration* that defaults to nullptr.
  • Unit tests cover general limits, provider override, and CreateConfiguredSdk wiring for both traces and logs.

How changes were tested

  • Added SdkBuilder.SpanLimitsFromAttributeLimits and SdkBuilder.SpanLimitsOverrideAttributeLimits.
  • Added programmatic tests that emit log records through a recording exporter and that read GetSpanLimits() on the configured tracer provider.

I could not run the C++ test binaries in this environment (no local CMake/Bazel build of opentelemetry-cpp). CI should run sdk_builder_test and programmatic_configuration_test.

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

…roviders

The YAML parser already accepted attribute_limits, but SdkBuilder
ignored them. Pass the general limits into CreateTracerProvider and
CreateLoggerProvider, and use them when the provider has no
model-specific limits. Provider limits still take precedence.

Fixes open-telemetry#4467
@ayush-singh-0601
ayush-singh-0601 requested a review from a team as a code owner August 21, 2026 15:30
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.97959% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.72%. Comparing base (1c2b007) to head (a336cf9).

Files with missing lines Patch % Lines
sdk/src/configuration/sdk_builder.cc 98.31% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4468      +/-   ##
==========================================
+ Coverage   82.67%   82.72%   +0.05%     
==========================================
  Files         516      517       +1     
  Lines       20197    20257      +60     
==========================================
+ Hits        16696    16755      +59     
- Misses       3501     3502       +1     
Files with missing lines Coverage Δ
...de/opentelemetry/sdk/configuration/document_node.h 100.00% <ø> (ø)
...e/opentelemetry/sdk/configuration/optional_value.h 100.00% <100.00%> (ø)
...entelemetry/sdk/configuration/ryml_document_node.h 100.00% <ø> (ø)
...lude/opentelemetry/sdk/configuration/sdk_builder.h 100.00% <ø> (ø)
sdk/src/configuration/configuration_parser.cc 79.81% <100.00%> (-0.08%) ⬇️
sdk/src/configuration/ryml_document_node.cc 80.85% <100.00%> (+0.45%) ⬆️
sdk/src/configuration/sdk_builder.cc 62.72% <98.31%> (+1.54%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ayush-singh-0601

Copy link
Copy Markdown
Author

can you please any changes that i need to make or is it fine

@ayush-singh-0601

Copy link
Copy Markdown
Author

all checks are passed , please tell if any more changes needed

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Requesting a minor change noted below.

Comment thread sdk/include/opentelemetry/sdk/configuration/sdk_builder.h
@ayush-singh-0601

Copy link
Copy Markdown
Author

@dbarker done

@dbarker dbarker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. Diving deeper into the spec and use cases I'm requested a change to the limit models and application methods to meet the spec.

Comment thread sdk/src/configuration/sdk_builder.cc Outdated
}
else
{
ApplyGeneralAttributeLimits(span_limits, attribute_limits);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach does not fully meet the spec in that the AttributeLimits are applied at the YAML node limit group level (SpanLimits and LogRecordLimits) instead of per individual limit.

If both a general and a model-specific limit are implemented, then the SDK MUST first attempt to use the model-specific limit, if it isn’t set, then the SDK MUST attempt to use the general limit. If neither are defined, then the SDK MUST try to use the model-specific limit default value, followed by the global limit default value.

With the following example a user may set the top-level attribute_limits then want to override specific limit fields in the provider configs while leaving some limits to retain the default values. Note that the schema supports explicitly setting null for each limit.

attribute_limits:
  attribute_value_length_limit: 4096
  attribute_count_limit: null 

logger_provider:
  limits:
    attribute_value_length_limit: 1024 
    attribute_count_limit:  null   # `logger_provider.limits` default expected

tracer_provider:
  limits:
    attribute_value_length_limit: null  # `attribute_limits` value expected
    attribute_count_limit:  null # `tracer_provider.limits` default expected
    event_count_limit: 64
    link_count_limit: 64
    event_attribute_count_limit: 8
    link_attribute_count_limit: 8

A user may reasonably expect logger_provider.limits and tracer_provider.limits from the above to resolve to:

logger_provider:
  limits:
    attribute_value_length_limit: 1024 # set from explicit `logger_provider.limits` value
    attribute_count_limit:  128  # set from `logger_provider.limits` default

tracer_provider:
  limits:
    attribute_value_length_limit: 4096 # from explicit `attribute_limits` value
    attribute_count_limit:  128 # from the `tracer_provider.limits` default
    event_count_limit: 64
    link_count_limit: 64
    event_attribute_count_limit: 8
    link_attribute_count_limit: 8

The issue is that the c++ model for AttributeLimitsConfiguration, SpanLimitsConfiguration, and LogRecordLimitsConfiguration do not represent individual limits as optional. We need to change the limit types from native numeric values to a type that can represent set or null (unset). Then the limit merge algorithm can be implemented to meet the spec.

Please consider this and update the design to meet the spec. Breaking changes to the model classes are okay now since the configuration libraries are still marked experimental and just need to be communicated in the CHANGELOG.

Make each limit on AttributeLimits, SpanLimits, and LogRecordLimits
optional so omitted keys and YAML null are unset. Merge uses the
model-specific value if set, else the general attribute_limits value,
else the model-specific default.
@ayush-singh-0601

Copy link
Copy Markdown
Author

@dbarker updated. Limit fields are optional now so omitted/null is distinct from a set value. Merge is model-specific if set, else general attribute_limits, else the model default.

@ayush-singh-0601

Copy link
Copy Markdown
Author

Thanks for syncing main into the branch. I checked the latest run, and all eight GitHub Actions workflows are currently marked action_required, so they have not actually executed yet. Could you approve them when convenient? The previous run did show IWYU, formatting, and several C++14/CMake failures, so once the fresh run is available I will address any remaining PR-specific issues together. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CONFIGURATION] General attribute limits

2 participants