Changed TraceIdRatioBasedSampler.GetLowerLong to use the correct bytes for sampling decision #5707
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.
Changes
Changed TraceIdRatioBasedSampler.GetLowerLong to use the correct bytes for sampling decision. Previously it was using the first 8 bytes to base the sampling decision on. Byte 0 in this case is the most significant byte not the least significant byte. As a result, changed it to use bytes 8->16 as those are the actual
LowerLong
. I discovered this while testing the with XrayIds where the first 4 bytes aren't random (based on current timestamp). Looking at this issue, open-telemetry/opentelemetry-specification#1413 (comment), seems like we're supposed to use the last 8 bytes to maintain compatibility with 64-bit TraceIds since those are random. I also looked at the Python Implementation and the Java Implementaiton of the TraceIdRatioBasedSampler and they both also seem to be using the last 8 bytes (least significant 8 bytes to byte 8->15 where byte 0 is the most significant byte).Testing:
I created a sample app and copied over the sampling code to verify that the bytes being used currently are the most significant bytes and this was the result:
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes