Skip to content
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

rv not set in tracestate for consistent56 sampling #1468

Closed
anuragagarwal561994 opened this issue Sep 21, 2024 · 2 comments
Closed

rv not set in tracestate for consistent56 sampling #1468

anuragagarwal561994 opened this issue Sep 21, 2024 · 2 comments

Comments

@anuragagarwal561994
Copy link

Component(s)

samplers

What happened?

Description

rv value is not set in the tracestate

Steps to Reproduce

use consistent56 sampling for your traces

Expected Result

rv should be set and passed in the tracestate but it is not

Actual Result

rv value is not passed

Component version

1.39.0-alpha

Log output

Request headers : {"Traceparent": "00-55bc3cfaa3eeeafcd2c03a7f68b83799-cc5a2666503c8e6b-01", "Tracestate": "ot=th:8"}

Additional context

I also wanted to understand even if the trace is not sampled if the rv should be passed to the subsequent system, may be the distributed system might want to be able to use this rv value to may be sample at its end.

So for example may be the sampling percentage for the trace in the current system is 1% but the next system it is 5%, so shouldn't rv be passed ahead so that the other system doesn't need to compute the same?

@PeterF778
Copy link
Contributor

The rv value is optional. When it is not present, the lower 56 bits of the TraceID are the source of randomness. See "Explicit trace randomness" and "Presumption of TraceID randomness" in Randomness requirements .... Since TraceID is always propagated, repeating the 14 hex characters for rv is not efficient, if the values are the same.

The rv value is supposed to be set for the ROOT span by all Consistent Probability Samplers when they do not see the Random flag in TraceFlags. However, current versions of OTel SDK do not generate this flag, and the samplers just assume that TraceID has sufficient randomness. Which is formally not correct.

Once rv gets into tracestate, it is propagated to all child spans, even if some spans are not sampled.

@anuragagarwal561994
Copy link
Author

Understood that this is the expected behaviour. We can close the issue however I would want to also quickly highlight my use-case.

So I have to sample some other logs in my system, but I want these logs to be connectable to my traces. Hence I thought that if I use the same rv value as my trace is using, then I can achieve this consistently. However every distributed system had to have this computation. But I think it's not a very difficult logic as well to implement, I am using like

long rv = Long.parseLong(traceId, traceId.length() - 14, traceId.length(), 16)

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

No branches or pull requests

4 participants