fix(tracing): format _dd.p.ksr with decimal notation instead of scientific notation#17086
Conversation
…tific notation Very small sampling rates (e.g. 0.000001) were formatted using Python's :.6g format which outputs scientific notation like "1e-06". This changes to explicit rounding at the integer level and :.6f formatting to always produce decimal notation with up to 6 decimal digits, trailing zeros stripped (e.g. "0.000001"). Fixes APMAPI-1869 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codeowners resolved as |
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: fbfb615 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Performance SLOsComparing candidate brian.marks/fix-ksr-scientific-notation (fbfb615) with baseline main (e49a662) 🟡 Near SLO Breach (2 suites)🟡 djangosimple - 30/30✅ appsecTime: ✅ 19.703ms (SLO: <22.300ms 📉 -11.6%) vs baseline: +0.3% Memory: ✅ 68.746MB (SLO: <73.500MB -6.5%) vs baseline: +5.1% ✅ exception-replay-enabledTime: ✅ 1.399ms (SLO: <1.450ms -3.5%) vs baseline: -0.3% Memory: ✅ 66.720MB (SLO: <71.500MB -6.7%) vs baseline: +4.7% ✅ iastTime: ✅ 19.735ms (SLO: <22.250ms 📉 -11.3%) vs baseline: ~same Memory: ✅ 68.743MB (SLO: <75.000MB -8.3%) vs baseline: +4.9% ✅ profilerTime: ✅ 15.145ms (SLO: <16.550ms -8.5%) vs baseline: +0.1% Memory: ✅ 60.457MB (SLO: <61.000MB 🟡 -0.9%) vs baseline: +4.9% ✅ resource-renamingTime: ✅ 19.613ms (SLO: <21.750ms -9.8%) vs baseline: ~same Memory: ✅ 68.720MB (SLO: <73.500MB -6.5%) vs baseline: +5.0% ✅ span-code-originTime: ✅ 20.087ms (SLO: <28.200ms 📉 -28.8%) vs baseline: +0.9% Memory: ✅ 68.532MB (SLO: <75.000MB -8.6%) vs baseline: +4.5% ✅ tracerTime: ✅ 19.749ms (SLO: <21.750ms -9.2%) vs baseline: +0.4% Memory: ✅ 68.738MB (SLO: <75.000MB -8.3%) vs baseline: +4.9% ✅ tracer-and-profilerTime: ✅ 21.067ms (SLO: <23.500ms 📉 -10.4%) vs baseline: -0.3% Memory: ✅ 70.709MB (SLO: <75.000MB -5.7%) vs baseline: +4.8% ✅ tracer-dont-create-db-spansTime: ✅ 19.796ms (SLO: <21.500ms -7.9%) vs baseline: ~same Memory: ✅ 68.814MB (SLO: <75.000MB -8.2%) vs baseline: +5.1% ✅ tracer-minimalTime: ✅ 16.760ms (SLO: <17.500ms -4.2%) vs baseline: ~same Memory: ✅ 68.566MB (SLO: <75.000MB -8.6%) vs baseline: +4.7% ✅ tracer-nativeTime: ✅ 19.656ms (SLO: <21.750ms -9.6%) vs baseline: +0.5% Memory: ✅ 68.603MB (SLO: <72.500MB -5.4%) vs baseline: +4.8% ✅ tracer-no-cachesTime: ✅ 17.627ms (SLO: <19.650ms 📉 -10.3%) vs baseline: +0.5% Memory: ✅ 68.686MB (SLO: <75.000MB -8.4%) vs baseline: +4.8% ✅ tracer-no-databasesTime: ✅ 19.299ms (SLO: <20.100ms -4.0%) vs baseline: ~same Memory: ✅ 68.608MB (SLO: <75.000MB -8.5%) vs baseline: +4.7% ✅ tracer-no-middlewareTime: ✅ 19.402ms (SLO: <21.500ms -9.8%) vs baseline: +0.1% Memory: ✅ 68.750MB (SLO: <75.000MB -8.3%) vs baseline: +4.9% ✅ tracer-no-templatesTime: ✅ 19.662ms (SLO: <22.000ms 📉 -10.6%) vs baseline: +1.1% Memory: ✅ 68.836MB (SLO: <73.500MB -6.3%) vs baseline: +5.0% 🟡 recursivecomputation - 8/8✅ deepTime: ✅ 310.980ms (SLO: <320.950ms -3.1%) vs baseline: -0.2% Memory: ✅ 37.513MB (SLO: <38.750MB -3.2%) vs baseline: +4.8% ✅ deep-profiledTime: ✅ 328.699ms (SLO: <359.150ms -8.5%) vs baseline: ~same Memory: ✅ 43.745MB (SLO: <46.000MB -4.9%) vs baseline: +4.5% ✅ mediumTime: ✅ 7.297ms (SLO: <7.400ms 🟡 -1.4%) vs baseline: +0.1% Memory: ✅ 36.687MB (SLO: <38.000MB -3.5%) vs baseline: +6.0% ✅ shallowTime: ✅ 1.015ms (SLO: <1.050ms -3.3%) vs baseline: +1.6% Memory: ✅ 36.707MB (SLO: <38.000MB -3.4%) vs baseline: +6.1%
|
The _set_attribute method stores string tags in span._meta, not span.context._meta. The CI failure showed the KSR values were correct but the assertion was reading from the wrong location. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4505c37328
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
emmettbutler
left a comment
There was a problem hiding this comment.
seems well-scoped and appropriate
Description
Fix
_dd.p.ksrspan tag formatting for very small sampling rates. Previously, rates below 0.001 were formatted using Python's:.6gformat which outputs scientific notation (e.g.0.000001→"1e-06"). This changes to explicit integer-level rounding and:.6fformatting to always produce decimal notation with up to 6 decimal digits, trailing zeros stripped.Related PRs:
Fixes APMAPI-1869
Testing
tests/tracer/test_sampler.py::test_ksr_formattingcovering:"1"(trailing zeros stripped)"0.000001"(6 decimal precision boundary)"0"(below precision, rounds to zero)"0.000001"(rounds up to one millionth)"0.5"(simple case)"0.765432"(truncation at 6 decimal places)Risks
None — the formatting change only affects
_dd.p.ksrstring values for very small rates. Values ≥ 0.001 produce identical output to the previous:.6gformat.Additional Notes
Uses
math.floor(rate * 1e6 + 0.5) / 1e6instead ofround(rate * 1e6) / 1e6to avoid Python's banker's rounding which would round0.0000005down to0instead of up to0.000001.