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

Python ASGI documentation causes errors in FastAPI

Open minboost opened this issue 2 years ago • 4 comments

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.

minboost avatar Jul 09 '22 22:07 minboost

Routing to @getsentry/team-web-sdk-backend for triage. ⏲️

getsentry-release avatar Jul 11 '22 14:07 getsentry-release

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.

vladanpaunovic avatar Jul 19 '22 07:07 vladanpaunovic

Updated labels based on the above. If it's wrong please let me know!

kerenkhatiwada avatar Jul 19 '22 19:07 kerenkhatiwada

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 🥀

github-actions[bot] avatar Aug 10 '22 00:08 github-actions[bot]

Documentation was updated.

antonpirker avatar Oct 17 '22 10:10 antonpirker