Starlite
The Starlite integration adds support for the Starlite framework.
Install sentry-sdk
from PyPI with the starlite
extra:
Copied
pip install --upgrade 'sentry-sdk[starlite]' uvicorn
Copied
from starlite import Starlite, get
import sentry_sdk
from sentry_sdk.integrations.starlite import StarliteIntegration
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
enable_tracing=True,
integrations=[StarliteIntegration()],
)
app = Starlite(route_handlers=[])
Copied
from starlite import Starlite, get
sentry_sdk.init(...) # same as above
@get("/hello")
async def hello_world() -> str:
1 / 0
return "Hello!"
app = Starlite(route_handlers=[hello_world])
Save the file above as app.py
and start the development server with:
Copied
uvicorn app:app
When you point your browser to http://localhost:8000/hello a transaction will be created in the Performance section of sentry.io. Additionally, the ZeroDivisionError
we've snuck into our hello_world
handler will be sent to sentry.io and will be connected to the transaction.
It takes a couple of moments for the data to appear in sentry.io.
Note
Starlite was renamed to Litestar with the release of version 2.0. We don't support Litestar yet, so this guide only applies to Starlite 1.51.14 and below.
- Starlite: 1.48.0 - 1.51.14
- Python: 3.8+
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- pypi:sentry-sdk
- Version:
- 1.45.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/