Using @sentry_sdk.trace
with concurrent futures messes up span hierarchy
#4241
Labels
@sentry_sdk.trace
with concurrent futures messes up span hierarchy
#4241
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.25.1
Steps to Reproduce
I am starting (calling) a bunch of futures, before I actually await them concurrently using
asyncio.gather
.The code looks like this:
I might be able to work around this in this toy example by using explicit
isolation_scope
myself somehow.However, my real usecase happens deep within the
graphql
library, somewhere here:https://github.com/graphql-python/graphql-core/blob/416247c1d511350445c23096f9491fbef424b69b/src/graphql/execution/execute.py#L431-L470
Expected Result
I expect the futures to create sibling spans, as they are being "started" in the same caller function.
Actual Result
Instead of the calls ending up with sibling spans, they end up as parent->child spans instead.
As the first async fn has not "finished" yet when I "start" the next one, it is on the top of the span hierarchy.
Example trace: https://sentry-sdks.sentry.io/discover/trace/9f5c02338db64a91901d28c3d90541b7
The text was updated successfully, but these errors were encountered: