-
Notifications
You must be signed in to change notification settings - Fork 33
Add specs to check randomness of ID generation #743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add specs to check randomness of ID generation #743
Conversation
| generate | ||
| .parReplicateA(16) // don't choose too high or the test might sometimes fail by chance (birthday paradoxon) | ||
| .map { ids => | ||
| assert(Eq.eqv(ids.distinct, ids), s"got only ${ids.distinct.size} distinct IDs instead of 16") |
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.
I think it's better to compare just the sizes of collections.
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.
I can change it, no problem, but may I ask why do you think it's better? We're on List here, so order is no issue. I only see a minor speed improvement as benefit.
|
|
||
| it should "generate distinct SpanId instances when using ThreadLocalRandom" in { | ||
| val instance = implicitly[SpanId.Gen[IO]] | ||
| GenAssertions.assertAllDistinct(instance.gen).unsafeRunSync() |
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.
Why not just SpanId.gen[IO]?
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.
Same below
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.
No particular reason, changed it :)
Check that SpanIDs and TraceIds are not repeating within a small sample to detect issues with the random generator used or the resolved implicit Gen instances. Relates to trace4cats#740.
7a6218b to
ef7343e
Compare
Check that SpanIDs and TraceIds are not repeating within a small sample to detect issues with the random generator used or the resolved implicit
Geninstances.Proposed in #740 (comment). As the upstream issue in CE still exists, two test cases fail right now. Hence marked as draft, will update once resolved.