Skip to content

[SDK] Round probability sampler ratios below 2^-56 instead of falling back to 1.0 - #4814

Open
ayush-that wants to merge 1 commit into
open-telemetry:mainfrom
ayush-that:composable-ratio-below-min
Open

ayush-that wants to merge 1 commit into
open-telemetry:mainfrom
ayush-that:composable-ratio-below-min

Conversation

@ayush-that

Copy link
Copy Markdown
Contributor

Part of #4798

Changes

ValidateRatio treated positive ratios below 2^-56 as invalid and fell back to 1.0, so ProbabilitySampler(1e-18) sampled every span. It now accepts any ratio in [0, 1.0], and the threshold rounds as for any other ratio. A ratio rounding to a threshold of 2^56 drops every span, as open-telemetry/opentelemetry-specification#5457 proposes. Both ProbabilitySampler and ComposableProbabilitySampler use ValidateRatio.

ratio before after
0 drop all drop all
(0, 2^-57) warn, sample all drop all
[2^-57, 2^-56) warn, sample all sample at 2^-56
[2^-56, 1.0] sample at ratio sample at ratio
< 0, > 1.0, NaN warn, sample all warn, sample all
  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.69%. Comparing base (8e92c48) to head (8fd02ac).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4814      +/-   ##
==========================================
- Coverage   86.70%   86.69%   -0.01%     
==========================================
  Files         530      530              
  Lines       21206    21205       -1     
==========================================
- Hits        18384    18381       -3     
- Misses       2822     2824       +2     
Files with missing lines Coverage Δ
sdk/src/trace/samplers/ot_trace_state.cc 100.00% <100.00%> (ø)

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

@ayush-that
ayush-that marked this pull request as ready for review November 29, 2026 21:33
@ayush-that
ayush-that requested a review from a team as a code owner November 29, 2026 21:33

This branch has not been deployed

No deployments
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.

1 participant