Skip to content
This repository was archived by the owner on Mar 19, 2022. It is now read-only.
Open
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ class ZipkinGrpcInterceptor {
return;
}

let ctxSampled = grpcMetadataFromIncomingCtx.get('x-b3-sampled')[0];
if (!(ctxSampled in ['0', '1'])) {
ctxSampled = '0';
}
let ctxSampledAsString = grpcMetadataFromIncomingCtx.get('x-b3-sampled')[0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. while unlikely, the header could be not present (that's why the Option type is used)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grpcMetadataFromIncomingCtx is a grpc.Metadata type.
If the header is not present it returns an empty array []; Taking the zeroth value will then be an undefined.
An undefined is not equal to either '1' or 'true' and thus result to false.
So, this should be fine, right?

let ctxSampled = ctxSampledAsString === '1' || ctxSampledAsString === 'true';

const ctxTraceInfo = new TraceId({
traceId: new Some(ctxTraceId),
Expand Down