Skip to content

Commit

Permalink
feat: decode jaeger header (#735)
Browse files Browse the repository at this point in the history
* feat: decode jaeger header

* fix: gts fix

* fix: use const instead of variables

* fix: use const for headers

Co-authored-by: Uladzislau Kiva <vladislav.kiva@moneyman.ru>
Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 29, 2020
1 parent 4e3c44d commit 4a83613
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class JaegerHttpTraceFormat implements HttpTextFormat {
* @return {SpanContext} - returns a span context represented by the serializedString.
**/
function deserializeSpanContext(serializedString: string): SpanContext | null {
let headers = serializedString.split(':');
const headers = decodeURIComponent(serializedString).split(':');
if (headers.length !== 4) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ describe('JaegerHttpTraceFormat', () => {
});
});

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

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

it('should use custom header if provided', () => {
carrier[customHeader] =
'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01';
Expand Down

0 comments on commit 4a83613

Please sign in to comment.