-
-
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
Sentry creates three traces for a single http request (ESM, custom opentelemetry setup) #14065
Comments
Some more things that I tried
|
@mydea could this be related to #13763? The release notes for
This sounds promising, however I don't think |
Hy, your guess is right. This change was introduced in Sentry.init({
integrations: [Sentry.httpIntegration({ spans: false })]
}) As you wrote you get double spans when setting this to |
Hey @nlochschmidt So after hours of debugging and nearly loosing my mind, we found a solution. In your reproduction, two To fix this:
To sum up (we will update the Custom Otel Setup docs accordingly):
|
@s1gr1d @Lms24 I was starting to loose my mind as well 😂 Thank you! I can confirm that this works in the example project (with Sentry register call, with own register call). It's interesting that the Will try it in production next 🤞 |
Http instrumentation works because it's a built-in module. All other instrumentations (node fetch being another exception) like hapi, express, pg, etc. need to be initialized beforehand (via --import loader). |
Quick update here. We have been working with Option 2 using the loader from opentelemetry with On the downside I don't think the context isolation in Sentry is working properly because we are getting the wrong tags on our reported errors. Since this did work in my example project it has probably something else to do with our setup. I suggest to close this issue and I'll open another one if I can figure out the issue for that. |
Can you elaborate on that? Do you mean that you get tags that should be assigned to events in request A to events in request B? Also just to be sure: Are the wrong tags only added to errors? We were generally under the impression that request isolation should work with a custom otel setup for errors. There might be problems for spans/transactions but errors would be new 😅 |
updates the Custom Node Otel setup page by: - showing how users can now add their own HttpInstrumentation (possible since we added `httpIntegration({spans: false})` in 8.35.0 - adding a section discussing ESM loaders and that only one loader hook (either their own or Sentry's) should be registered (we learned about this in getsentry/sentry-javascript#14065) --------- Co-authored-by: Francesco Novy <[email protected]>
@Lms24 So we found the issue. We are initializing Sentry in a shared library and had an issue where Sentry was initialized twice (once with it's own OTEL and once with ours). This somehow caused some of the errors to not get the route and transaction in them. After aligning the versions and removing the double initialization it works now. |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.35.0
Framework Version
hapi 21.3.10
Link to Sentry event
No response
Reproduction Example/SDK Setup
https://github.com/nlochschmidt/sentry-duplicate-tracing-bug
Steps to Reproduce
curl localhost:3000
I get aspanId
andtraceId
from inside the handlerConsoleSpanExporter
will print the traces and spans collected after a short time.Expected Result
I expect to get a single trace with two spans (one for http and one for hapi).
Actual Result
What actually happens is that there are three traces and only one of them (
traceId: 9dbf48ed9eee5aa66cba36df77eef90b
) has the two spans that are expected, while the other two traces have only a single http root span.I can see some odd instrumentation scopes
@opentelemetry_sentry-patched/instrumentation-http
, but interestingly the@opentelemetry/instrumentation-http
is on one of the traces with a single span.Here is the output cleaned up a bit (full output in the example repo README):
It works as expected when removing Sentry
The text was updated successfully, but these errors were encountered: