fix: _dd.p.ksr formatting to use 6 significant digits without trailing zeros#288
fix: _dd.p.ksr formatting to use 6 significant digits without trailing zeros#288
_dd.p.ksr formatting to use 6 significant digits without trailing zeros#288Conversation
… zeros
Replace std::to_string() (which uses sprintf "%f" producing 6 trailing
decimal places) with snprintf "%.6g" which produces up to 6 significant
digits with no trailing zeros. This matches the behavior of Python's
f"{rate:.6g}" and Go's strconv.FormatFloat(rate, 'g', 6, 64).
Examples: 1.0 -> "1", 0.5 -> "0.5", 0.0 -> "0"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BenchmarksBenchmark execution time: 2026-03-12 15:33:47 Comparing candidate commit d9275b8 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics. scenario:BM_TraceTinyCCSource
|
Reformat the emplace_back call to match clang-format's expected style (arguments on one line with alignment) to fix the verify CI job. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🎯 Code Coverage (details) 🔗 Commit SHA: d9275b8 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #288 +/- ##
==========================================
- Coverage 87.76% 87.70% -0.07%
==========================================
Files 84 84
Lines 5658 5668 +10
==========================================
+ Hits 4966 4971 +5
- Misses 692 697 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The ksr trace tag should only be set when the sampling decision comes from an explicit source (agent rate, rule, or remote rule). When the DEFAULT mechanism is used — meaning no agent configuration has been received yet — the rate is a hardcoded 100% and ksr is meaningless. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40373eb to
913ad91
Compare
There was a problem hiding this comment.
Well done.
EDIT: I'm trying to enforce semantic commits, please prefix your commit message with fix: during the merge. Thanks.
_dd.p.ksr formatting to use 6 significant digits without trailing zeros
Co-authored-by: Damien Mehala <damien.mehala@datadoghq.com>
Fix two issues introduced by GitHub suggestion commits: 1. Correct the error condition: `ec == std::errc()` means success, not failure — changed to `ec != std::errc()` to properly detect errors. 2. Fix indentation from 4-space to 2-space to match project style and pass clang-format checks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Description
Fix
_dd.p.ksrformatting to use 6 significant digits without trailing zeros, usingstd::to_charswithstd::chars_format::general. Also skip setting_dd.p.ksrwhen the sampling mechanism is DEFAULT (no agent configuration received yet).Changes:
snprintfwithstd::to_charsfor_dd.p.ksrformattingstd::chars_format::generalwith 6 significant digits (matches Go tracer behavior)_dd.p.ksrwhenSamplingMechanism::DEFAULTis activestd::to_charsconversion failuresMotivation
The previous
snprintfapproach with%gformat produced inconsistent output compared to other tracers.std::to_charswithstd::chars_format::generalgives us precise control over significant digits while automatically removing trailing zeros.Additionally, setting
_dd.p.ksrwith the DEFAULT mechanism is meaningless since no sampling configuration has been received from the agent yet.Additional Notes
Jira ticket: [PROJ-IDENT]
🤖 Generated with Claude Code