Skip to content

Commit

Permalink
add test for baggage too large
Browse files Browse the repository at this point in the history
  • Loading branch information
wconti27 committed Dec 19, 2024
1 parent f427e9b commit 2f702c7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/dd-trace/src/opentracing/propagation/text_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class TextMapPropagator {
if (origin) {
this._addXrayBaggage(str, xrayOriginKey, origin, maxAdditionalCapacity)
}
if (e2eStart !== xrayDefaultStartTime) {
if (e2eStart !== xrayDefaultE2EStartTime) {
this._addXrayBaggage(str, xrayE2EStartTimeKey, e2eStart.toString(), maxAdditionalCapacity)
}

Expand Down Expand Up @@ -782,7 +782,7 @@ class TextMapPropagator {
}

_extractAwsXrayContext (carrier) {
if (!this._hasPropagationStyle('inject', 'xray')) {
if (!this._hasPropagationStyle('extract', 'xray')) {
return null
}

Expand Down
27 changes: 27 additions & 0 deletions packages/dd-trace/test/opentracing/propagation/text_map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,33 @@ describe('TextMapPropagator', () => {

expect(carrier['x-amzn-trace-id']).to.equal(expectedHeader + additionalParts)
})

it('should inject skip adding baggage to the X-Amzn-Trace-Id when exceeding the 256 byte limit', () => {
const baggageItems = {
bool: true,
a: 'b',
mySuperLongBaggageIReallyShouldLearnToPackLighter: 'datadog'.repeat(50),
shortBaggage: 'thisFits'
}
const spanContext = createContext({
baggageItems,
sampling: {
priority: 1
}
})

config.tracePropagationStyle.inject = ['xray']

const traceId = spanContext._traceId.toString().padStart(24, '0')
const spanId = spanContext._spanId.toString().padStart(16, '0')
const expectedHeader = `root=1-00000000-${traceId};parent=${spanId};sampled=1`
const additionalParts = ';bool=true;a=b;shortBaggage=thisFits'
const carrier = {}

propagator.inject(spanContext, carrier)

expect(carrier['x-amzn-trace-id']).to.equal(expectedHeader + additionalParts)
})
})

describe('extract', () => {
Expand Down

0 comments on commit 2f702c7

Please sign in to comment.