Skip to content

Commit b456550

Browse files
authored
fix baggage extraction (#4935)
1 parent 66f115c commit b456550

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

packages/dd-trace/src/opentracing/propagation/text_map.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ class TextMapPropagator {
339339
context._links.push(link)
340340
}
341341
}
342+
}
342343

343-
if (this._config.tracePropagationStyle.extract.includes('baggage') && carrier.baggage) {
344-
context = context || new DatadogSpanContext()
345-
this._extractBaggageItems(carrier, context)
346-
}
344+
if (this._hasPropagationStyle('extract', 'baggage') && carrier.baggage) {
345+
context = context || new DatadogSpanContext()
346+
this._extractBaggageItems(carrier, context)
347347
}
348348

349349
return context || this._extractSqsdContext(carrier)

packages/dd-trace/test/opentracing/propagation/text_map.spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ describe('TextMapPropagator', () => {
406406
})
407407

408408
it('should extract otel baggage items with special characters', () => {
409-
process.env.DD_TRACE_BAGGAGE_ENABLED = true
410409
config = new Config()
411410
propagator = new TextMapPropagator(config)
412411
const carrier = {
@@ -452,6 +451,20 @@ describe('TextMapPropagator', () => {
452451
expect(spanContextD._baggageItems).to.deep.equal({})
453452
})
454453

454+
it('should extract baggage when it is the only propagation style', () => {
455+
config = new Config({
456+
tracePropagationStyle: {
457+
extract: ['baggage']
458+
}
459+
})
460+
propagator = new TextMapPropagator(config)
461+
const carrier = {
462+
baggage: 'foo=bar'
463+
}
464+
const spanContext = propagator.extract(carrier)
465+
expect(spanContext._baggageItems).to.deep.equal({ foo: 'bar' })
466+
})
467+
455468
it('should convert signed IDs to unsigned', () => {
456469
textMap['x-datadog-trace-id'] = '-123'
457470
textMap['x-datadog-parent-id'] = '-456'

0 commit comments

Comments
 (0)