Skip to content

[CONFIGURATION] Apply default sampler when none is specified#4170

Merged
marcalff merged 9 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/config-default-sampler
Jun 27, 2026
Merged

[CONFIGURATION] Apply default sampler when none is specified#4170
marcalff merged 9 commits into
open-telemetry:mainfrom
RaviTriv:ravtrive/config-default-sampler

Conversation

@RaviTriv

@RaviTriv RaviTriv commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #4034

Changes

PR to apply default sampler when one is not set in the trace provider configuration. Updated the parser to apply ParentBasedSamplerConfiguration with AlwaysOnSamplerConfiguration as per the spec when no sampler is specified.

For significant contributions please make sure you have completed the following items:

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

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.90%. Comparing base (56848f9) to head (482af5d).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4170      +/-   ##
==========================================
+ Coverage   82.88%   82.90%   +0.03%     
==========================================
  Files         405      405              
  Lines       17287    17292       +5     
==========================================
+ Hits        14326    14334       +8     
+ Misses       2961     2958       -3     
Files with missing lines Coverage Δ
sdk/src/configuration/configuration_parser.cc 77.65% <100.00%> (+0.09%) ⬆️

... and 2 files with indirect coverage changes

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

@RaviTriv RaviTriv marked this pull request as ready for review June 19, 2026 09:46
@RaviTriv RaviTriv requested a review from a team as a code owner June 19, 2026 09:47
@RaviTriv RaviTriv force-pushed the ravtrive/config-default-sampler branch from 07322f1 to a75d53a Compare June 21, 2026 11:30
Comment thread sdk/test/configuration/yaml_trace_test.cc
@lalitb

lalitb commented Jun 25, 2026

Copy link
Copy Markdown
Member

I think there is one remaining default-sampler edge case. This PR handles the case where sampler is omitted entirely, but an explicit:

sampler:
  parent_based:

still leaves ParentBasedSamplerConfiguration::root as nullptr.

The config spec says ParentBasedSampler.root defaults to always_on when omitted. Since SdkBuilder::CreateParentBasedSampler() later calls CreateSampler(model->root), should we also apply the always_on default when parent_based.root is omitted?

@RaviTriv

Copy link
Copy Markdown
Contributor Author

I think there is one remaining default-sampler edge case. This PR handles the case where sampler is omitted entirely, but an explicit:

sampler:
  parent_based:

still leaves ParentBasedSamplerConfiguration::root as nullptr.

The config spec says ParentBasedSampler.root defaults to always_on when omitted. Since SdkBuilder::CreateParentBasedSampler() later calls CreateSampler(model->root), should we also apply the always_on default when parent_based.root is omitted?

Good catch! Updated the parser to apply the always_on default when parent_based.root is omitted.

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

LGTM, see a minor comment on the tests.

Comment thread sdk/test/configuration/yaml_trace_test.cc

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

LGTM, thanks for the fix

@marcalff marcalff merged commit 10a5a4f into open-telemetry:main Jun 27, 2026
71 checks passed
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] default sampler in config

4 participants