This repository was archived by the owner on Mar 19, 2022. It is now read-only.
The sampled value should be a boolean, not a string. Currently the result is that the trace is always sampled.#1
Open
wdittmer wants to merge 3 commits into
Open
The sampled value should be a boolean, not a string. Currently the result is that the trace is always sampled.#1wdittmer wants to merge 3 commits into
wdittmer wants to merge 3 commits into
Conversation
The sampled value should be a boolean, not a string. Currently the result is that the trace is always sampled.
| if (!(ctxSampled in ['0', '1'])) { | ||
| ctxSampled = '0'; | ||
| } | ||
| let ctxSampledAsString = grpcMetadataFromIncomingCtx.get('x-b3-sampled')[0]; |
There was a problem hiding this comment.
cool. while unlikely, the header could be not present (that's why the Option type is used)
Author
There was a problem hiding this comment.
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?
|
No we need to use Opion.None as false is not the same. reason is this:
undefined is "lack of a sampling decision" whereas false is "upstream
sampled and said no" make sense?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using a sample rate of 1%, I still saw traces from the nodejs application. After digging through it , it turns out that the sampled value is propagated as a string with either '0' or '1'. Further on in the trace of zipkin.js when the recordAnnotation is done it is checked with: if (!sampled) return; A string is always truthy, so it will always sample.
This pull request transforms the incoming string into a boolean.