-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(node): Ensure tracing without performance (TWP) works #11564
Conversation
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important tests.
To me, this change screams that we need to decouple our propagation logic from opentlemetry as it seem like OTEL is a bit incompatible with our concept for twp.
|
||
const scopes = getCapturedScopesOnSpan(span); | ||
|
||
const isolationScope = (scopes.isolationScope || getIsolationScope()).clone(); | ||
const scope = scopes.scope || getCurrentScope(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we moving this above the early return? As far as I can see it doesn't do anything right? (Also the "Update the isolation scope, isolate this request" comment is a bit orphanded now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I moved stuff around multiple times here, will move it back down!
This fixes the node SDK to make tracing without performance work as expected.
This has three aspects:
tracePropagationTargets
, even if the span is not sampled.The fix for 2. was to have a fallback behavior if we don't have a scope linked to a context yet (we'll just use the current scope then). This is needed because we won't necessarily have an assigned scope yet at the time this is called, because at this point in time this is still a floating context. This also meant removing the fallback code to look at the remote span context (because we'll always have a scope now).
The fix for 3. was to move this out of the http integration and do this in the sampler instead.
The fix for 1. was a bit more elaborate, because we require different things to solve the http instrumentation and the fetch instrumentation.
For fetch, we leverage our sampler, which can attach trace state that even unsampled spans will have. We attach the URL as trace state which we can read in the propagator, ensuring this works even for unsampled spans.
Sadly, for http this is not sufficient, because our usage of
onlyIfParentForOutgoingRequest
lead to some spans being created outside of the sampler. By removing this option (see 3) and doing stuff in the sampler instead, we can ensure that all spans for http are handled properly.This also bumps our node-fetch otel instrumentation to 1.2.0 which fixes headers for Node 21 (tests were actually failing without this!).