Commit 793a2ad
Add _dd.p.ksr propagated tag for Knuth sampling rate (#10802)
Add _dd.p.ksr propagated tag for Knuth sampling rate
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: remove unused imports and update OT tests for _dd.p.ksr propagation
- Remove unused imports in KnuthSamplingRateTest (CodeNarc violations)
- Update OT31ApiTest and OT33ApiTest to expect _dd.p.ksr in
x-datadog-tags when agent-rate sampler runs (UNSET priority)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: add t.ksr to expected tracestate in OT compatibility tests
The _dd.p.ksr propagated tag also appears in W3C tracestate as t.ksr.
Update OT31 and OT33 test expectations for the UNSET context priority
case where the agent-rate sampler runs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix forbidden API usage in formatKnuthSamplingRate
Replace String#replaceAll (a forbidden API in this codebase) with
manual character-based trailing-zero stripping logic that has the
same semantics but avoids the regex-based method.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix: correct _dd.p.ksr ordering in OT x-datadog-tags expectations
The PTagsCodec headerValue method outputs tags in order: dm, tid, ksr.
The test datadogTags list had ksr before tid, causing a comparison
failure. Reorder to match the actual output: dm, tid, ksr.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: add _dd.p.ksr to expected meta maps in DDAgentApiTest
The ksr implementation now adds _dd.p.ksr tag to spans with agent
sampling rate, so the msgpack serialization test expectations need
to include it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: update propagation tests to include _dd.p.ksr in expected headers
- OpenTelemetryTest: fix x-datadog-tags ordering (tid before ksr)
- DatadogPropagatorTest: add ksr to expected tags when UNSET priority
- OpenTracing32Test: add ksr and tid handling for UNSET priority case
All follow PTagsCodec ordering: dm → tid → ksr
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: add ksr and tid handling to OpenTracing31Test inject extract
Update the test inject extract expectations to include _dd.p.ksr=1 in
x-datadog-tags and t.ksr:1 in tracestate for the UNSET sampling case,
following PTagsCodec ordering: dm -> tid -> ksr.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address PR feedback: fix locale bug, move ksr formatting to PropagationTags
- Use Locale.ROOT in String.format to prevent locale-sensitive decimal
separators (e.g. comma in fr_FR) from corrupting x-datadog-tags
- Move formatKnuthSamplingRate() from DDSpan to PTagsFactory so
propagation encoding logic stays in the propagation layer
- Change updateKnuthSamplingRate signature to accept double instead of
pre-formatted String
- Use indexOf('.') instead of contains(".") for minor perf improvement
- Update test to exercise formatting through PropagationTags API
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ci: retry - transient JBoss 503 failure in smoke tests
Merge branch 'master' into brian.marks/add-ksr-tag
Merge branch 'master' into brian.marks/add-ksr-tag
Address PR feedback: rename datadogTags to expectedDataTags, store ksr as primitive double
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Optimize formatKnuthSamplingRate: replace String.format with char-array arithmetic
Replace String.format(Locale.ROOT, "%.6g", rate) with manual char-array
formatting that avoids Formatter/stream/boxing allocations. Benchmarks
show ~30x improvement (320ns -> 11ns).
Additionally, cache the TagValue in updateKnuthSamplingRate() so that
getKnuthSamplingRateTagValue() is a simple volatile read (~1.2ns) instead
of re-formatting and re-looking up the TagValue on every header injection.
Add JMH benchmark (KnuthSamplingRateFormatBenchmark) comparing all three
approaches and expand test coverage to all magnitude buckets.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Eliminate String.format entirely from formatKnuthSamplingRate
Implement scientific notation (rates < 1e-4) with manual char-array
formatting, removing the last String.format dependency. The method
now uses zero Formatter/Locale allocations for all rate values.
Add test coverage for scientific notation: 1e-05, 5e-05, 1.23457e-05,
1e-07, 5.5e-10.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Optimize KSR update path with static rate→TagValue cache
Two changes:
1. Benchmark (address dougqh feedback):
- Switch to Throughput mode + @threads(8) to surface GC pressure
- @State(Scope.Thread): each thread gets its own PTags, models real traces
- Add updateRateFreshTrace: resets instance cache each iteration to model
per-trace cost (the actual hot path Doug was concerned about)
- Update run instructions to include -t 8 -prof gc
2. Static cache for KSR TagValue (Option A):
- Add static volatile cachedKsrRate + cachedKsrTagValue to PTags
- On updateKnuthSamplingRate, check static cache before formatting
- Eliminates char[]+String allocation on the per-trace path in steady state
(every new PTags starts with NaN; without the cache, each trace root
re-formats even when the rate is constant)
- Race is benign: two threads computing the same rate produce equal TagValues
- gc.alloc.rate.norm: updateRateFreshTrace goes from 80 B/op → ≈ 0 B/op
structurally (not JIT-dependent)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>1 parent 828c9cc commit 793a2ad
File tree
13 files changed
+605
-24
lines changed- dd-java-agent/instrumentation
- opentelemetry
- opentelemetry-0.3/src/test/groovy
- opentelemetry-1.4/src/test/groovy/opentelemetry14/context/propagation
- opentracing
- opentracing-0.31/src/test/groovy
- opentracing-0.32/src/test/groovy
- dd-trace-core/src
- jmh/java/datadog/trace/core/propagation/ptags
- main/java/datadog/trace/core
- propagation
- ptags
- test/groovy/datadog/trace
- common/writer
- core
- dd-trace-ot/src
- ot31CompatibilityTest/groovy
- ot33CompatibilityTest/groovy
13 files changed
+605
-24
lines changedLines changed: 24 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
276 | 278 | | |
277 | | - | |
278 | | - | |
| 279 | + | |
| 280 | + | |
279 | 281 | | |
280 | | - | |
281 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
282 | 296 | | |
283 | 297 | | |
284 | | - | |
285 | | - | |
| 298 | + | |
| 299 | + | |
286 | 300 | | |
287 | 301 | | |
288 | 302 | | |
289 | 303 | | |
290 | | - | |
291 | | - | |
| 304 | + | |
| 305 | + | |
292 | 306 | | |
293 | 307 | | |
294 | 308 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
292 | 301 | | |
293 | | - | |
294 | 302 | | |
295 | 303 | | |
296 | 304 | | |
297 | 305 | | |
298 | 306 | | |
299 | 307 | | |
300 | 308 | | |
301 | | - | |
302 | | - | |
| 309 | + | |
| 310 | + | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
| |||
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | | - | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
312 | 322 | | |
313 | 323 | | |
314 | 324 | | |
315 | | - | |
316 | | - | |
| 325 | + | |
| 326 | + | |
317 | 327 | | |
318 | 328 | | |
319 | 329 | | |
| |||
Lines changed: 114 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
649 | 655 | | |
650 | 656 | | |
651 | 657 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
133 | 143 | | |
134 | 144 | | |
135 | 145 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
| |||
0 commit comments