sentry-docs
sentry-docs copied to clipboard
Python ASGI documentation causes errors in FastAPI
Core or SDK?
Platform/SDK
Which part? Which one?
https://docs.sentry.io/platforms/python/guides/asgi/
Description
Integrating with FastAPI with the following line throws various errors, depending on what is implemented
asgi_app = SentryAsgiMiddleware(asgi_app)
Some errors could include:
@app.middleware("http")
AttributeError: 'SentryAsgiMiddleware' object has no attribute 'middleware'
@app.on_event('shutdown')
AttributeError: 'SentryAsgiMiddleware' object has no attribute 'on_event'
Integrating the middleware as described in the FastAPI docs fixes the problem:
asgi_app.add_middleware(SentryAsgiMiddleware)
Suggested Solution
Update the documents with an example for FastAPI and/or a note that some ASGI middleware must be installed differently than shown in the example.
Routing to @getsentry/team-web-sdk-backend for triage. ⏲️
Hey @minboost, until now Sentry didn't have a native support for FastAPI so users had to use our ASGI integration.
Well, worry no more! 💪
This week, we will release a beta version of FastAPI integration and I recommend you give it a try and see whether it resolves this issue for you or not.
If curious, you can always check our FastAPI milestone for checking what will come up.
Updated labels based on the above. If it's wrong please let me know!
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog
or Status: In Progress
, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Documentation was updated.