-
Notifications
You must be signed in to change notification settings - Fork 837
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
fix(instr-http): respect requireParent flag when INVALID_SPAN_CONTEXT is used #4788
base: main
Are you sure you want to change the base?
fix(instr-http): respect requireParent flag when INVALID_SPAN_CONTEXT is used #4788
Conversation
|
a89e6b3
to
f14254a
Compare
f14254a
to
658e198
Compare
ping to other reviewers @pichlermarc @JamieDanielson @dyladan @trentm |
I think it is correct that no span ( However, I'm not super-confident, so I was hoping to get review from some of the longer term reviewers. Should I can understand the desire to use |
Yeah, my use case is incrementally adding tracing to an existing service that gets a lot of traffic, and I want to be able to gradually increase the coverage of traces to decrease the risk of accidentally degrading prod performance from over-instrumentation. It has been a while since I made this change, so I forgot exactly what was happening, but I think we had I'm not sure whether |
@pichlermarc @JamieDanielson @dyladan @trentm could I get a review when you have time? Much appreciated :) |
@pichlermarc @JamieDanielson @dyladan @trentm would love to land this PR if possible |
I agree with this. I think what we're still trying to sort out is how we get into a state of an invalid span context here. @reberhardt7 Is there an issue with the client / is the client not behaving according to spec? Or is this somehow being set intentionally while rolling out the incremental instrumentation? |
Which problem is this PR solving?
The http instrumentation (and many other instrumentation libraries) create spans with INVALID_SPAN_CONTEXT to create NonRecordingSpans when we enable
requireParent
and no parent is present: https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L769That works fine; those spans are not exported. However, when we create child spans, those end up becoming real spans that are exported. E.g. if we have an http server, when a request comes in, we create a span with INVALID_SPAN_CONTEXT, and then if the http request handler makes an outbound request, the instrumentation sees that it has a parent span (even though it is invalid) and creates a real child span, initiating a new trace.
The opentelemetry sdk creates new traces for descendants of INVALID_SPAN_CONTEXT:
opentelemetry-js/packages/opentelemetry-sdk-trace-base/src/Tracer.ts
Line 91 in ecc88a3
Short description of the changes
This checks whether the parent span is recording, and does not create a real child span if the parent isn't recording.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Added unit test to verify fix
Checklist: