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

Auto-enable Starlette and FastAPI integrations

Open antonpirker opened this issue 3 years ago • 1 comments

Problem Statement

Right now the users have to set the integrations by themselves. Better would be auto enabling it like Django.

Solution Brainstorm

Detect starlette and fastfapi python modules and if present enable the integrations. See other integration how they do it. Also update the guide in documentation, the wizard and the static "for" pages to reflect this.

TODO

  • [X] Auto-enable Integrations
  • [ ] Fix tests to reflect new behavior
  • [ ] Update Starlette Guide: https://docs.sentry.io/platforms/python/guides/starlette/
  • [ ] Update FastAPI Guide: https://docs.sentry.io/platforms/python/guides/fastapi/
  • [ ] Update wizard snippets for Starlette: https://github.com/getsentry/sentry-docs/blob/master/src/wizard/python/starlette.md
  • [ ] Update wizard snippets for FastAPI: https://github.com/getsentry/sentry-docs/blob/master/src/wizard/python/fastapi.md
  • [ ] Update "for" page for Starlette: https://github.com/getsentry/static-sites/blob/master/packages/www/src/pages/for/starlette.js
  • [ ] Update "for" page for FastApi: https://github.com/getsentry/static-sites/blob/master/packages/www/src/pages/for/fastapi.js

antonpirker avatar Aug 01 '22 12:08 antonpirker

In case that the ASGIMiddleware is used when also the integrations are auto enabled I now output an error message during startup: The Python SDK can now automatically support ASGI frameworks like Starlette and FastAPI. Please remove 'SentryAsgiMiddleware' from your project. See https://docs.sentry.io/platforms/python/guides/asgi/ for more information.

There is also a PR to improve the linked documentation: https://github.com/getsentry/sentry-docs/pull/5390

antonpirker avatar Aug 05 '22 13:08 antonpirker

@antonpirker, please extract the leftovers of this issue into a separate one and close this.

vladanpaunovic avatar Sep 05 '22 11:09 vladanpaunovic