Skip to content

Commit

Permalink
remove ability to propagate baggage on its own to avoid app crashes (#…
Browse files Browse the repository at this point in the history
…5209)

* remove ability to propagate baggage on its own to bandage app crash

* modify unit test

* tidy up code

* add clarifying comment

* code fix

* code clean up season 2

* attempted code fix
  • Loading branch information
ida613 authored and rochdev committed Feb 7, 2025
1 parent 7a48bcd commit 58ddb47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit 58ddb47

Please sign in to comment.