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

Wrapping "invalid" SpanContexts in Spans does not preserve the SpanContext #6037

Closed
PeterF778 opened this issue Dec 1, 2023 · 4 comments
Closed
Labels
Bug Something isn't working

Comments

@PeterF778
Copy link
Contributor

Describe the bug

The static method in the Span interface wrap(SpanContext spanContext) is expected to create a Span object corresponding to the provided spanContext. However, if the provided context is "invalid", it is not used, and a generic invalid Span is returned.

Steps to reproduce

Create an "invalid" SpanContext by calling
Span span = SpanContext.create("0", "0", TraceFlags.getDefault(), myTraceState)
where myTraceState is a TraceState that I want to use.

What did you expect to see?
I expect that span.getSpanContext().getTraceState() will return an object equivalent to myTraceState that I supplied,

What did you see instead?

Instead I see the default (empty) TraceState returned.

What version and what artifacts are you using?

opentelemetry-java-sdk, version 1.31

Additional context

The bigger picture: When working on client session sampling, we want all traces comprising the session to be sampled as a group - either all of them are dropped or all of them are sampled. Using consistent probability sampling, this can be achieved by setting the same randomness (via TraceState) for all traces belonging to a session. This needs to be done before the sampling decision for the root spans is made, thus necessitating manipulation of "invalid" SpanContexts.

@PeterF778 PeterF778 added the Bug Something isn't working label Dec 1, 2023
@PeterF778
Copy link
Contributor Author

I volunteer to fix this.

@jkwatson
Copy link
Contributor

jkwatson commented Dec 5, 2023

@PeterF778 can you reference a part of the specification that describes what the API should do in this case? If not, we should get spec clarification before changing it.

@PeterF778
Copy link
Contributor Author

@PeterF778 can you reference a part of the specification that describes what the API should do in this case? If not, we should get spec clarification before changing it.

Here is the relevant part of the specification. When describing wrapping SpanContext in Spans it says "GetContext MUST return the wrapped SpanContext", it does not say that this behavior is expected only for valid SpanContexts.

@jack-berg
Copy link
Member

jack-berg commented Dec 8, 2023

Resolved in #6044.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants