diff --git a/packages/dd-trace/src/opentracing/propagation/text_map.js b/packages/dd-trace/src/opentracing/propagation/text_map.js index afca108111..b117ae0ae5 100644 --- a/packages/dd-trace/src/opentracing/propagation/text_map.js +++ b/packages/dd-trace/src/opentracing/propagation/text_map.js @@ -339,11 +339,11 @@ class TextMapPropagator { context._links.push(link) } } + } - if (this._config.tracePropagationStyle.extract.includes('baggage') && carrier.baggage) { - context = context || new DatadogSpanContext() - this._extractBaggageItems(carrier, context) - } + if (this._hasPropagationStyle('extract', 'baggage') && carrier.baggage) { + context = context || new DatadogSpanContext() + this._extractBaggageItems(carrier, context) } return context || this._extractSqsdContext(carrier) diff --git a/packages/dd-trace/test/opentracing/propagation/text_map.spec.js b/packages/dd-trace/test/opentracing/propagation/text_map.spec.js index 4598ffeda7..c6247330a6 100644 --- a/packages/dd-trace/test/opentracing/propagation/text_map.spec.js +++ b/packages/dd-trace/test/opentracing/propagation/text_map.spec.js @@ -406,7 +406,6 @@ describe('TextMapPropagator', () => { }) it('should extract otel baggage items with special characters', () => { - process.env.DD_TRACE_BAGGAGE_ENABLED = true config = new Config() propagator = new TextMapPropagator(config) const carrier = { @@ -452,6 +451,20 @@ describe('TextMapPropagator', () => { expect(spanContextD._baggageItems).to.deep.equal({}) }) + it('should extract baggage when it is the only propagation style', () => { + config = new Config({ + tracePropagationStyle: { + extract: ['baggage'] + } + }) + propagator = new TextMapPropagator(config) + const carrier = { + baggage: 'foo=bar' + } + const spanContext = propagator.extract(carrier) + expect(spanContext._baggageItems).to.deep.equal({ foo: 'bar' }) + }) + it('should convert signed IDs to unsigned', () => { textMap['x-datadog-trace-id'] = '-123' textMap['x-datadog-parent-id'] = '-456'