-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(node): Do not emit fetch spans when tracing is disabled #13003
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
Conversation
Ensure that TWP works with fetch, but we do not emit a span. Otherwise, if a user does not use our tracing functionality but adds their own fetch instrumentation, they get spans twice.
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "node-otel-sdk-trace", | |||
"name": "node-otel-sdk-node", |
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.
noticed this name was actually not consistent.
|
||
createTestServer(done) | ||
.get('/api/v0', headers => { | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['__requestUrl']).toBeUndefined(); |
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.
this is actually not needed anymore, we do not set this anywhere, removed it in all places.
const url = request.origin; | ||
return _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url); | ||
ignoreRequestHook: (request: FetchRequest) => { | ||
const url = getAbsoluteUrl(request.origin, request.path); |
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.
Noticed that this was actually incorrect, we just took the origin as URL, oops.
size-limit report 📦
|
|
||
test('Sends an API route transaction to OTLP', async ({ baseURL }) => { | ||
waitForTransaction('node-otel-without-tracing', transactionEvent => { | ||
throw new Error('THIS SHOULD NEVER HAPPEN!'); |
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.
nice idea to ensure something is not sent 😅
Ensure that TWP works with fetch, but we do not emit a span. Otherwise, if a user does not use our tracing functionality but adds their own fetch instrumentation, they get spans twice.
The benefit we have with fetch is that fetch is instrumented via diagnostics channel, which means that this can be instrumented multiple times. So if we instrument it, on the plus side this does not interfere with a user instrumenting it again themselves if they want.
However, with the previous implementation our integration would always emit spans. If a user is using our own sampler, this is "OK" because it will sample it out. But if a user does not use our sampler, the spans we emit there get sent unintentionally.
With this change, we ensure to ignore requests if tracing is disabled. In order to make TWP work, we instead manually inject the propagator headers into the fetch request in this scenario.
Part of #12984
Fixes #12969