Skip to content

Commit c0877fc

Browse files
IlyasShabisabrenner
authored andcommitted
fix(standalone): stamp _dd.apm.enabled on every span (#9506)
1 parent d4a09f5 commit c0877fc

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

integration-tests/appsec/standalone-asm.spec.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,16 @@ describe('Standalone ASM', () => {
121121
assert.ok(groups.indexOf(rootGroup) < groups.indexOf(outboundGroup))
122122
assert.strictEqual(String(outboundSpan.parent_id), String(rootSpan.span_id))
123123

124-
// Load-bearing: the delayed child chunk must carry the billing marker,
125-
// even though its parent is a local (non-remote) span.
126-
assert.strictEqual(rootSpan.metrics['_dd.apm.enabled'], 0)
127-
assert.strictEqual(outboundGroup[0], outboundSpan)
128-
assert.strictEqual(outboundSpan.metrics['_dd.apm.enabled'], 0)
124+
// Load-bearing: every span in every chunk must carry the billing marker,
125+
// including the delayed child whose parent is a local (non-remote) span.
126+
for (const group of groups) {
127+
for (const span of group) {
128+
assert.strictEqual(
129+
span.metrics['_dd.apm.enabled'], 0,
130+
`span ${span.name}/${span.resource} missing _dd.apm.enabled:0`
131+
)
132+
}
133+
}
129134
})
130135

131136
it('should keep fifth req because RateLimiter allows 1 req/min', async () => {

packages/dd-trace/src/span_processor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SpanProcessor {
6262
active.push(span)
6363
} else {
6464
const formattedSpan = spanFormat(span, isFirstSpanInChunk, this._processTags)
65-
if (isFirstSpanInChunk && stampApmDisabled) {
65+
if (stampApmDisabled) {
6666
formattedSpan.metrics[APM_TRACING_ENABLED_KEY] = 0
6767
}
6868
isFirstSpanInChunk = false

packages/dd-trace/test/span_processor.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ describe('SpanProcessor', () => {
235235
sinon.assert.calledWith(spanFormat.getCall(3), finishedSpan, false, processor._processTags)
236236
})
237237

238-
it('should add APM disabled marker to first span in a chunk when APM tracing is disabled', () => {
238+
it('should add APM disabled marker to every span in a chunk when APM tracing is disabled', () => {
239239
config.apmTracingEnabled = false
240240
config.flushMinSpans = 2
241241
const processor = new SpanProcessor(exporter, prioritySampler, config)
@@ -249,7 +249,7 @@ describe('SpanProcessor', () => {
249249
processor.process(finishedSpan)
250250

251251
assert.strictEqual(firstFormatted.metrics[APM_TRACING_ENABLED_KEY], 0)
252-
assert.ok(!Object.hasOwn(secondFormatted.metrics, APM_TRACING_ENABLED_KEY))
252+
assert.strictEqual(secondFormatted.metrics[APM_TRACING_ENABLED_KEY], 0)
253253
sinon.assert.calledWith(exporter.export, [firstFormatted, secondFormatted])
254254
})
255255

0 commit comments

Comments
 (0)