sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Set correct parent span in async environment

Open antonpirker opened this issue 3 years ago • 4 comments

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.9.10

Steps to Reproduce

  • Have a FastAPI app
  • Have a FastAPI middleware like this one: https://github.com/getsentry/demo-app-django-react/blob/main/backend/fastapi/main.py#L80-L101
  • Do something in this middleware that creates a span (like the redis call in the span
  • Reload an endpoint that uses this middleware
  • Go to the "Performance" section of sentry.io and look at the event
  • You will see this: Screenshot 2022-10-05 at 08 55 07

Expected Result

The redis span should be under the CounterMiddleware.

Actual Result

The redis span is under the AsyncExitStackMiddleware

antonpirker avatar Oct 05 '22 15:10 antonpirker

This is also related with this amazing issue: https://github.com/getsentry/sentry-python/issues/1187

antonpirker avatar Oct 06 '22 12:10 antonpirker

and https://github.com/getsentry/sentry-python/issues/772

sl0thentr0py avatar Oct 06 '22 12:10 sl0thentr0py

also https://github.com/getsentry/sentry-python/issues/772#issuecomment-1270020139

sl0thentr0py avatar Oct 06 '22 13:10 sl0thentr0py

and https://github.com/getsentry/sentry-python/issues/1333#issuecomment-1270030888

sl0thentr0py avatar Oct 06 '22 13:10 sl0thentr0py