Repository navigation
fix(standalone): stamp _dd.apm.enabled on every exported chunk - #9483
Conversation
Overall package sizeSelf size: 7.51 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.2 | 124.41 kB | 440.65 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
🎉 All green!🧪 All tests passed 🔄 Datadog retried 1 test - 1 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: bacd947 | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9483 +/- ##
==========================================
+ Coverage 96.54% 98.44% +1.89%
==========================================
Files 927 943 +16
Lines 126652 127248 +596
Branches 10431 10827 +396
==========================================
+ Hits 122274 125266 +2992
+ Misses 4378 1982 -2396 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BridgeAR
left a comment
There was a problem hiding this comment.
LGTM, just left a nit. I believe the test case could be a bit more robust, but it should be fine
| if (isFirstSpanInChunk && stampApmDisabled) { | ||
| formattedSpan.metrics[APM_TRACING_ENABLED_KEY] = 0 |
There was a problem hiding this comment.
Nit (the single variable is better to optimize away)
| if (isFirstSpanInChunk && stampApmDisabled) { | |
| formattedSpan.metrics[APM_TRACING_ENABLED_KEY] = 0 | |
| if (stampApmDisabled) { | |
| formattedSpan.metrics[APM_TRACING_ENABLED_KEY] = 0 | |
| stampApmDisabled = false |
What does this PR do?
Moves the
_dd.apm.enabled:0billing marker from a span-start hook to the chunk export path in SpanProcessor.When
apmTracingEnabled === false, the first span of every exported chunk is stamped with the marker. The old start-time hook in standalone/index.js is removed (redundancy)Motivation
Standalone ASM customers (
DD_APM_TRACING_ENABLED=false) rely on the_dd.apm.enabled:0marker to opt out of APM host billing. The intake emits an APM billing point for a trace chunk unless at least one span in that chunk carries this marker.Current behavior: At span start, we stamped
_dd.apm.enabled:0only on spans with no parent or a remote parent. The assumption was that this local root would always be present in every exported chunk.Issue with outbound spans: When a child span outlives its parent, the parent flushes first in its own chunk (with the marker), and the child flushes later in a separate chunk. That second chunk contains no local root — the child had a local parent at start, so the guard skipped it. The intake sees a chunk with no marker and charges APM host billing.
Reported case: a fastify request span finished immediately, while its outbound http.request child kept running for 10s. The outbound arrived alone, unmarked, and triggered APM billing on an ASM-only service.
Solution: Make the decision at chunk export instead of span start. The export loop is the one place that unambiguously knows the chunk boundaries, so stamping the first span there guarantees every exported chunk carries the marker.
Additional Notes