sentry-python
sentry-python copied to clipboard
FastAPI spans have wrong parent span?
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.9.10
Steps to Reproduce
I have a FastAPI demo app: https://github.com/getsentry/demo-app-django-react/tree/main/backend/fastapi
The app has a middleware called CounterMiddleware that increments a counter in Redis.
It seems that the spans has the wrong parent. See:

Expected Result
The redis span should be under the CounterMiddleware and not under the AsyncExitStackMiddleware.
Actual Result
The redis span is drawn under the wrong parent span. (checking the parent span id shows that it has the wrong parent span id)