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
fix(propagator-jaeger): zero pad extracted trace id to 32 characters
fixes #1983
  • Loading branch information
sid-maddy committed Apr 5, 2021
commit ce54776102e38201eedc2d34ac62c6709204a588
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ function deserializeSpanContext(serializedString: string): SpanContext | null {
if (headers.length !== 4) {
return null;
}
const [traceId, spanId, , flags] = headers;

const [_traceId, spanId, , flags] = headers;

const traceId = _traceId.padStart(32, '0');
const traceFlags = flags.match(/^[0-9a-f]{2}$/i) ? parseInt(flags) & 1 : 1;

return { traceId, spanId, isRemote: true, traceFlags };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('JaegerHttpTracePropagator', () => {

assert.deepStrictEqual(extractedSpanContext, {
spanId: '45fd2a9709dadcf1',
traceId: '9c41e35aeb6d1272',
traceId: '00000000000000009c41e35aeb6d1272',
isRemote: true,
traceFlags: TraceFlags.SAMPLED,
});
Expand All @@ -132,7 +132,7 @@ describe('JaegerHttpTracePropagator', () => {

assert.deepStrictEqual(extractedSpanContext, {
spanId: '5ac292c4a11a163e',
traceId: 'ac1f3dc3c2c0b06e',
traceId: '0000000000000000ac1f3dc3c2c0b06e',
isRemote: true,
traceFlags: TraceFlags.SAMPLED,
});
Expand Down