Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class TextMapPropagator {
if (context === null) {
context = extractedContext
if (this._config.tracePropagationExtractFirst) {
this._extractBaggageItems(carrier, context)
return context
}
} else {
Expand All @@ -344,10 +345,7 @@ class TextMapPropagator {
}
}

if (this._hasPropagationStyle('extract', 'baggage') && carrier.baggage) {
context = context || new DatadogSpanContext()
this._extractBaggageItems(carrier, context)
}
this._extractBaggageItems(carrier, context)

return context || this._extractSqsdContext(carrier)
}
Expand Down Expand Up @@ -596,6 +594,9 @@ class TextMapPropagator {
}

_extractBaggageItems (carrier, spanContext) {
if (!this._hasPropagationStyle('extract', 'baggage')) return
if (!carrier || !carrier.baggage) return
if (!spanContext) return
const baggages = carrier.baggage.split(',')
for (const keyValue of baggages) {
if (!keyValue.includes('=')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ describe('TextMapPropagator', () => {
expect(spanContextD._baggageItems).to.deep.equal({})
})

it('should extract baggage when it is the only propagation style', () => {
// temporary test. On the contrary, it SHOULD extract baggage
it('should not extract baggage when it is the only propagation style', () => {
config = new Config({
tracePropagationStyle: {
extract: ['baggage']
Expand All @@ -462,7 +463,7 @@ describe('TextMapPropagator', () => {
baggage: 'foo=bar'
}
const spanContext = propagator.extract(carrier)
expect(spanContext._baggageItems).to.deep.equal({ foo: 'bar' })
expect(spanContext).to.be.null
})

it('should convert signed IDs to unsigned', () => {
Expand Down
Loading