fix(tracer): eliminate IEEE 754 flakes in TestSamplingDecision#4530
Conversation
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 5557b5e | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-03-12 17:19:27 Comparing candidate commit 4268687 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 157 metrics, 7 unstable metrics.
|
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
0957c7c
into
main
What does this PR do?
Four assertions in
TestSamplingDecisionwere updated:Fixed denominators (three cases):
assert.InDelta(t, 0.8, float64(n)/1000, 0.15)is equivalent toassert.InDelta(t, 800, n, 150). Operating on integers eliminates the division and any rounding entirely.Dynamic denominator (one case):
assert.InDelta(t, 0.5, float64(a)/float64(b), 0.15)cannot be trivially scaled becausebvaries. Instead the tolerance range[0.35, 0.65]is expressed as exact integer inequalities by multiplying through by 20 (since0.35 = 7/20and0.65 = 13/20):All integer values involved are well within the range where
float64conversion is exact (< 2^53), so testify's internal float64 comparison is lossless.Motivation
TestSamplingDecisionhad fourassert.InDeltacalls that compared a float64 ratio (computed via division) against an expected value with a tolerance. When the actual sample count landed exactly on the boundary, IEEE 754 floating-point arithmetic produced a result that exceeded the tolerance by one ULP, causing spurious test failures.The canonical example:
keptSpans = 650withfloat64(650)/float64(1000) = 0.65. The mathematical value|0.8 - 0.65| = 0.15is exactly at the tolerance boundary, but the IEEE 754 result is0.15000000000000002, which failsassert.InDelta(..., 0.15).Reviewer's Checklist
make lintlocally.make testlocally.make generatelocally.Unsure? Have a question? Request a review!