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

tracerOptions.RandomNumber accepts uint64 generator, but ProbabilisticSampler compares as 63bit integer. #489

Closed
funny-falcon opened this issue Feb 25, 2020 · 2 comments · Fixed by #490
Labels

Comments

@funny-falcon
Copy link
Contributor

Requirement - what kind of business use case are you trying to solve?

Correct probabilistic sampler tuning.

Problem - what in Jaeger blocks you from solving the requirement?

tracerOptions.RandomNumber accepts func() uint64 generator. User assumes it should generate full 64bit integer, and documentation of RandomNumber doesn't mention anything contradict to this assumption.

func (tracerOptions) RandomNumber(randomNumber func() uint64) TracerOption {

but Probabilistic sampler acts as if it gots 63bit integer from random generator:

const maxRandomNumber = ^(uint64(1) << 63) // i.e. 0x7fffffffffffffff

s.samplingBoundary = uint64(float64(maxRandomNumber) * s.samplingRate)

and default random generator actually returns 63bit integers:

number := uint64(generator.Int63())

Proposal - what do you suggest to solve the problem or improve the existing situation?

  • either change default generator to return full 64bit integer and fix Probabilistic sampler to react on full 64bit integer
  • or document tracerOption.RandomNumber that generator function should return 63bit integer
@yurishkuro
Copy link
Member

I think it's ok if the custom generator is 64 or 63 bits, but if the sampler is expecting 63bits, then it should unset the top bit of the ID before making a comparison here:

return s.samplingBoundary >= id.Low, s.tags

@funny-falcon
Copy link
Contributor Author

Master said, and follower was enlighted :-)

Your suggestion is really "beautiful in its simplicity"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants