-
Notifications
You must be signed in to change notification settings - Fork 288
Unset highest bit of traceID in probabilistic sampler #490
Conversation
This commit fixes interconnection of ProbabilisticSampler.IsSampled and tracerOptions.RandomNumber: - RandomNumber accepts `func() uint64` and doesn't documents it should return 63bit integer - IsSampled performed check as if random number were 63bit integer. This fix (suggested by Yuri Shkuro) truncates highest bit before comparison in IsSampled, therefore it doesn't matter if random number is 63bit or 64bit. Signed-off-by: Sokolov Yura <funny.falcon@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #490 +/- ##
=======================================
Coverage 88.43% 88.43%
=======================================
Files 59 59
Lines 3581 3581
=======================================
Hits 3167 3167
Misses 303 303
Partials 111 111
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s add a test
I've added test for 64bit values |
sampled, tags := sampler.IsSampled(TraceID{Low: (testMaxID + 10) | 1<<63}, testOperationName) | ||
assert.False(t, sampled) | ||
assert.Equal(t, testProbabilisticExpectedTags, tags) | ||
sampled, tags = sampler.IsSampled(TraceID{Low: (testMaxID - 20) | 1<<63}, testOperationName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ineffectual assignment to tags
(from ineffassign
)
Signed-off-by: Sokolov Yura <funny.falcon@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This commit fixes interconnection of ProbabilisticSampler.IsSampled and tracerOptions.RandomNumber:
func() uint64
and doesn't documents it should return 63bit integerThis fix (suggested by Yuri Shkuro) truncates highest bit before comparison in IsSampled,
therefore it doesn't matter if random number is 63bit or 64bit.
fixes #489
Signed-off-by: Sokolov Yura funny.falcon@gmail.com