Skip to content

Commit

Permalink
fix(propagator-jaeger):extract 1 digit traceFlag(0) return 1 (#2906)
Browse files Browse the repository at this point in the history
* fix(propagator-jaeger):extract 1 digit traceFlag(0) return 1

* update CHANGELOG

* fix quota

* Parse jaeger flags with radix 16

Co-authored-by: legendecas <[email protected]>

Co-authored-by: Daniel Dyla <[email protected]>
Co-authored-by: legendecas <[email protected]>
  • Loading branch information
3 people authored Apr 24, 2022
1 parent a0a670a commit 4584c36
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file.

* fix: sanitize attributes inputs [#2881](https://github.com/open-telemetry/opentelemetry-js/pull/2881) @legendecas
* fix: support earlier API versions [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan
* fix: support extract one digit '0' in jaeger traceFlag [#2905](https://github.com/open-telemetry/opentelemetry-js/issues/2905) @shmilyoo

### :books: (Refine Doc)

Expand All @@ -34,6 +35,8 @@ All notable changes to this project will be documented in this file.
* chore: require changelog entry to merge PR [#2847](https://github.com/open-telemetry/opentelemetry-js/pull/2847) @dyladan
* chore: remove peer API check [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan
* chore: merge lerna subdirectories into a single monorepo [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan
* `opentelemetry-propagator-jaeger`
* [#2906](https://github.com/open-telemetry/opentelemetry-js/pull/2906) fix: support extract one digit '0' in jaeger traceFlag ([@shmilyoo](https://github.com/shmilyoo))

## 1.1.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function deserializeSpanContext(serializedString: string): SpanContext | null {

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

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

it('should extract context of a sampled span from carrier with 1 bit flag', () => {
it('should extract context of a sampled span from carrier with 1 bit flag(1)', () => {
carrier[UBER_TRACE_ID_HEADER] =
'9c41e35aeb6d1272:45fd2a9709dadcf1:a13699e3fb724f40:1';
const extractedSpanContext = trace.getSpanContext(
Expand All @@ -174,6 +174,21 @@ describe('JaegerPropagator', () => {
});
});

it('should extract context of a sampled span from carrier with 1 bit flag(0)', () => {
carrier[UBER_TRACE_ID_HEADER] =
'9c41e35aeb6d1272:45fd2a9709dadcf1:a13699e3fb724f40:0';
const extractedSpanContext = trace.getSpanContext(
jaegerPropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter)
);

assert.deepStrictEqual(extractedSpanContext, {
spanId: '45fd2a9709dadcf1',
traceId: '00000000000000009c41e35aeb6d1272',
isRemote: true,
traceFlags: TraceFlags.NONE,
});
});

it('should extract context of a sampled span from UTF-8 encoded carrier', () => {
carrier[UBER_TRACE_ID_HEADER] =
'ac1f3dc3c2c0b06e%3A5ac292c4a11a163e%3Ac086aaa825821068%3A1';
Expand Down

0 comments on commit 4584c36

Please sign in to comment.