Skip to content

Conversation

@ybasket
Copy link
Contributor

@ybasket ybasket commented Apr 26, 2022

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.

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.

@ybasket ybasket requested a review from janstenpickle April 26, 2022 21:14
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")
Copy link
Member

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.

Copy link
Contributor Author

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()
Copy link
Member

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]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below

Copy link
Contributor Author

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 :)

ybasket added 3 commits May 21, 2022 19:43
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.
@ybasket ybasket force-pushed the add-random-generation-specs branch from 7a6218b to ef7343e Compare May 21, 2022 17:47
@ybasket ybasket marked this pull request as ready for review May 21, 2022 21:34
@ybasket ybasket requested a review from catostrophe May 21, 2022 21:34
@ybasket ybasket merged commit b7b0d08 into trace4cats:master May 22, 2022
@catostrophe catostrophe added the enhancement New feature or request label May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants