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

The use of TraceState together with HttpTraceContext seems to be problematic. #1091

Closed
dyladan opened this issue Oct 14, 2020 · 4 comments
Closed

Comments

@dyladan
Copy link
Member

dyladan commented Oct 14, 2020

The use of TraceState together with HttpTraceContext seems to be problematic.

HttpTraceContext simply serializes spanContext.traceState.

Therefore the caller of inject is responsible to get the needed data into spanContext.traceState before calling inject().

But the spec tells that SpanContext is immutable therefore it's not allowed to set a the new TraceState.

What is the correct way to get an updated TraceState into a span?

Originally posted by @Flarna in open-telemetry/opentelemetry-js#1596 (comment)

@bogdandrutu
Copy link
Member

@dyladan I am confused, I see this as:

  • Parse traceparent and save tid, sid, flags
  • Parse tracestate and get the tracestate part (default empty)
  • Construct the immutable object with all properties parsed from previous steps.

Is this an implementation detail, do I miss something?

@dyladan
Copy link
Member Author

dyladan commented Oct 14, 2020

According to spec, TraceState is immutable and set operations create a new TraceState. SpanContext is also immutable. Therefore if I need to update the TraceState in the injection step of the propagator (something we wish to do at Dynatrace), it is not possible. The SpanContext cannot be updated with the new TraceState because it is immutable.

@bogdandrutu
Copy link
Member

bogdandrutu commented Oct 14, 2020

Therefore if I need to update the TraceState in the injection step of the propagator (something we wish to do at Dynatrace), it is not possible. The SpanContext cannot be updated with the new TraceState because it is immutable.

Why not? you just need to create a new SpanReference, it is a bit slower indeed, but it is thread safe. If you make the object mutable you need to synchronize and leads to undefined behaviors when multiple threads try to change the SpanContext/TraceState - one thread can change the context on the other thread

@bogdandrutu
Copy link
Member

@dyladan Can I close this issue?

@dyladan dyladan closed this as completed Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants