Skip to content

Commit

Permalink
fix(propagator-jaeger): zero pad extracted trace id to 32 characters
Browse files Browse the repository at this point in the history
fixes #1983
  • Loading branch information
sid-maddy committed Apr 5, 2021
1 parent 8e2e2a9 commit ce54776
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit ce54776

Please sign in to comment.