-
Notifications
You must be signed in to change notification settings - Fork 517
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
OpenTelemetry FastAPI and Requests #1940
Comments
Hey @zukwung Thanks for reporting this! I put this on our backlog. I think you are right that the problem is the second instance not getting the trace information right and thus it can not attach its transaction to the trace. How did you create the first, correct screenshot? |
@antonpirker i modified this line to |
Hm. In the line above Instead of picking the first element to call with I was guessing that the trace would be always in the first element. But It could be because we have two services with the same implementation that the header is in there twice and the last one is the correct one? I will probably look at this beginning of next week. Great debuggin @zukwung ! |
great, thanks @antonpirker, let me know if you need more info |
@zukwung sorry for still not tackling this. I am kind of swamped with other things. Will take some time until I can do this. |
no worries @antonpirker, for our use cases I went ahead and just used the usual Sentry SDK, but I really appreciate the efforts Sentry has with OpenTelemetry, keep it up :) |
I think i'm facing a similar issue. Sentry swallows the trace header from |
Facing the same issue. We have service A (sampling rate
Span information as printed by OTEL in Service A:
Completely commenting out the below line fixes the issue with the broken traces (I get a complete trace) and everything looks great in the Sentry UI. We then also get the
What we want to achieve is to use OTEL with Sentry as the tracing backend and having the W3C TraceContext headers be propagated so that we can use them with our logging to correlate log messages based on the trace-id. Let me know if there's anything we can help out with. Update: Although the issue looks very similar our issue might not be exactly the same (could be). In our case the |
I followed @zukwung's idea of modifying the
However
Which means even though the context and |
If OpenTelementry is enabled, the sentry-trace headers should not be applied by Sentry intregration, but only by the OTel propagator. Fixes #1940
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.16.0
Steps to Reproduce
Expected Result
A single trace with both requests
Actual Result
Multiple traces with each request
Additional Info
I spent a day or two debugging this issue, and it seems to boil down to how the trace-id is extracted in the propagator. I believe the ASGI middleware is generating a span somewhere that I haven't been able to find, since the scope here already has the new span somewhere, see a sample below.
Because of the asgi middleware, the
sentry_trace = getter.get(carrier, SENTRY_TRACE_HEADER_NAME)
becomessentry_trace: [['ecf45d41418a4ab8a5723e6c24b598d3-9cdd27733f0c0d37-', 'bd345b67708c6000341cdd61eeeb5583-3b4d0fe494390136-1']]
, which means sentry uses the first trace id to then send to sentry, causing the behaviour above. I tried changing the selection to select the last element, which works, but I'm not sure how this would impact usage in other places, otherwise I would open a PR. I believe there is no issue with the outgoing request because looking at the sentry span in inject in the propagator, the current span seems to be correct, see below for more info.asgi carrier info
sentry span in propagator inject
The text was updated successfully, but these errors were encountered: