Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
add tests for 64bit id probabilistic sampling
Browse files Browse the repository at this point in the history
Signed-off-by: Sokolov Yura <funny.falcon@gmail.com>
  • Loading branch information
funny-falcon committed Mar 2, 2020
1 parent 23de8b9 commit 00ac23a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ func TestProbabilisticSampler(t *testing.T) {
sampled, tags = sampler.IsSampled(TraceID{Low: testMaxID - 20}, testOperationName)
assert.True(t, sampled)
assert.Equal(t, testProbabilisticExpectedTags, tags)

t.Run("test_64bit_id", func(t *testing.T) {
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)
assert.True(t, sampled)
assert.Equal(t, testProbabilisticExpectedTags, tags)
})

sampler2, _ := NewProbabilisticSampler(0.5)
assert.True(t, sampler.Equal(sampler2))
assert.False(t, sampler.Equal(NewConstSampler(true)))
Expand Down

0 comments on commit 00ac23a

Please sign in to comment.