Skip to content

[CONFIGURATION] Build composable samplers from file configuration - #4366

Merged
dbarker merged 13 commits into
open-telemetry:mainfrom
ayush-that:composable-sampler-plumbing
Aug 7, 2026
Merged

dbarker merged 13 commits into
open-telemetry:mainfrom
ayush-that:composable-sampler-plumbing

Conversation

@ayush-that

@ayush-that ayush-that commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4028

Follows up #4334, requested by @dbarker in #4334 (comment).

Schema reference https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/tracer_provider.yaml

Changes

The composable visit methods in SdkBuilder were placeholders. always_on, always_off, and probability built the legacy samplers, and parent_threshold and rule_based ignored their config and sampled everything. They now build the real composable samplers through a recursive visitor wrapped in CompositeSamplerFactory::Create, with a new predicate for rule_based matching (attribute values and patterns, span kinds, parent).

The composable probability ratio is now range checked at parse time, same as #4334, and ComposableProbabilitySampler guards against NaN instead of hitting std::llround(NaN * 2^56).

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

Copilot AI lite review requested due to automatic review settings August 5, 2026 20:58
@ayush-that
ayush-that requested a review from a team as a code owner August 5, 2026 20:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ayush-that
ayush-that force-pushed the composable-sampler-plumbing branch from 7289e33 to 0b042aa Compare August 5, 2026 20:59
@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.69951% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.91%. Comparing base (b1efe57) to head (1959086).

Files with missing lines Patch % Lines
sdk/src/configuration/sdk_builder.cc 72.23% 25 Missing ⚠️
sdk/src/trace/samplers/rule_based_predicate.cc 97.88% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4366      +/-   ##
==========================================
+ Coverage   81.79%   81.91%   +0.13%     
==========================================
  Files         493      494       +1     
  Lines       19474    19654     +180     
==========================================
+ Hits        15926    16097     +171     
- Misses       3548     3557       +9     
Files with missing lines Coverage Δ
...ion/composable_probability_sampler_configuration.h 100.00% <ø> (ø)
sdk/src/common/wildcard_match.h 100.00% <100.00%> (ø)
sdk/src/configuration/configuration_parser.cc 78.66% <100.00%> (+0.15%) ⬆️
sdk/src/trace/samplers/composable_probability.cc 100.00% <100.00%> (ø)
sdk/src/trace/samplers/ot_trace_state.cc 100.00% <100.00%> (ø)
sdk/src/trace/samplers/probability.cc 97.37% <100.00%> (-0.40%) ⬇️
sdk/src/trace/samplers/rule_based_predicate.cc 97.88% <97.88%> (ø)
sdk/src/configuration/sdk_builder.cc 52.78% <72.23%> (+3.13%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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 PR! Please see some initial feedback below.

Comment thread sdk/src/configuration/sdk_builder.cc Resolved
Comment thread CHANGELOG.md Resolved
@ayush-that
ayush-that requested review from dbarker and a lite review from Copilot August 6, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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. Please see feedback below on the rule based predicate.

@ayush-that
ayush-that requested review from dbarker and a balanced review from Copilot August 6, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ayush-that
ayush-that requested review from dbarker and a balanced review from Copilot August 6, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

: public opentelemetry::sdk::configuration::SamplerConfigurationVisitor
{
public:
// NOLINTBEGIN(misc-no-recursion)

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.

The yaml schema supports infinite sampler nesting due to the ExperimentalComposableRuleBasedSampler containing an array of ExperimentalComposableRuleBasedSamplerRule which each may contain a ExperimentalComposableRuleBasedSampler (See: schema/tracer_provider.yaml#L340).

Without a limit to the sampler nesting depth, a misconfigured yaml file may cause excessive resource usage and latency given that the nested samplers will be run in the Tracer::StartSpan method on the hot path. We need some protection for this.

Please add a comment here to clarify why the recursion is accepted, a depth limit (10 seems reasonable), and throw a configuration error when the limit is hit.

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 can be a follow up PR and is not blocking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you! I will do a follow up PR.

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. Please hold on that PR. I'm integrating this PR into #4367 and may address there. The composable sampler builders will move out of the SdkBuilder in that PR so there would be conflicts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okie.

@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.

Nice work! Please see this comment for a follow up PR. I plan to merge once CI passes.

bool match_span_kind_consumer = false;

// Significant digits used to format double attribute values for matching.
int double_precision = 6;

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.

nit - this type should be std::uint32_t and ranged checked before use. Okay for followup PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it.

@dbarker
dbarker merged commit c845387 into open-telemetry:main Aug 7, 2026
73 checks passed
@ayush-that
ayush-that deleted the composable-sampler-plumbing branch August 21, 2026 15:24
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.

[SDK] Implement ComposableSampler

3 participants