Learn about using Sentry with Starlite.

The Starlite integration adds support for the Starlite framework.

Install sentry-sdk from PyPI with the starlite extra:

pip install --upgrade 'sentry-sdk[starlite]' uvicorn

If you have the starlite package in your dependencies, the Starlite integration will be enabled automatically when you initialize the Sentry SDK.

Configuration should happen as early as possible in your application's lifecycle.

import sentry_sdk

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.

from starlite import Starlite, get

sentry_sdk.init(...)  # same as above

async def hello_world() -> str:
    1 / 0
    return "Hello!"

app = Starlite(route_handlers=[hello_world])

Save the file above as and start the development server with:

uvicorn app:app

When you point your browser to http://localhost:8000/hello a transaction will be created in the Performance section of Additionally, the ZeroDivisionError we've snuck into our hello_world handler will be sent to and will be connected to the transaction.

It takes a couple of moments for the data to appear in

  • 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").