Skip to content

Reject invalid ratios in the composable probability sampler - #9056

Merged
jack-berg merged 2 commits into
open-telemetry:mainfrom
eminfikret:fix/composable-probability-ratio-validation
Dec 1, 2026
Merged

jack-berg merged 2 commits into
open-telemetry:mainfrom
eminfikret:fix/composable-probability-ratio-validation

Conversation

@eminfikret

@eminfikret eminfikret commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9046.

ComposableSampler.probability() accepted ratios outside [0.0, 1.0] and NaN. These produced an invalid threshold and silently dropped every span.

The sampler now throws IllegalArgumentException with the same message as TraceIdRatioBasedSampler ("ratio must be in range [0.0, 1.0]"), and also rejects NaN.

A new parameterized test covers negative, greater-than-one, and NaN ratios. It fails on the original implementation and passes with the fix, along with the rest of ComposableProbabilitySamplerTest and the module's check task.

- Add parameterized tests for negative, greater than one and NaN ratios.

Refs open-telemetry#9046

Assisted-by: Claude Opus 5.5
Signed-off-by: Emin Fikret <emin.n.fikret@gmail.com>
@eminfikret
eminfikret requested a review from a team as a code owner November 24, 2026 13:30
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-12-01 23:29 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.53%. Comparing base (a91844f) to head (12a2267).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9056      +/-   ##
============================================
- Coverage     90.56%   90.53%   -0.03%     
- Complexity    11197    11254      +57     
============================================
  Files          1032     1040       +8     
  Lines         30524    30703     +179     
  Branches       3999     4015      +16     
============================================
+ Hits          27644    27797     +153     
- Misses         1909     1928      +19     
- Partials        971      978       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@eminfikret

Copy link
Copy Markdown
Contributor Author

Hi @jkwatson, let me know if any changes are needed. Thanks.

@jkwatson jkwatson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me

@jack-berg

Copy link
Copy Markdown
Member

Pushed a small commit 12a2267 to finish aligning validation with the spec. It expands validation to accept only zero or ratios in [2^-56, 1.0], matching the spec’s input range.

@jack-berg
jack-berg enabled auto-merge (squash) December 1, 2026 22:49
@jack-berg
jack-berg merged commit e91fe6d into open-telemetry:main Dec 1, 2026
34 checks passed
@otelbot

otelbot Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @eminfikret! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

[incubator] ComposableProbabilitySampler does not validate ratio range

3 participants