Quart

Learn about using Sentry with Quart.

The Quart integration adds support for the Quart Web Framework.

Install sentry-sdk from PyPI with the quart extra:

Copied
pip install --upgrade sentry-sdk[quart]

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

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

Copied
import sentry_sdk

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.
    profiles_sample_rate=1.0,
)

Copied
from quart import Quart

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

app = Quart(__name__)

@app.route("/")
async def hello():
    1/0  # raises an error
    return {"hello": "world"}

app.run()

When you point your browser to http://localhost:5000/ a transaction in the Performance section of sentry.io will be created. Additionally, an error event 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.

  • The Sentry Python SDK will install the Quart integration for all of your apps.

  • All exceptions leading to an Internal Server Error, from before/after serving functions, and background tasks are reported.

  • Request data is attached to all events: HTTP method, URL, headers. Sentry also excludes personally identifiable information (such as user IDs, usernames, cookies, authorization headers, IP addresses) unless you set send_default_pii to True.

  • Each request has a separate scope. Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request being handled.

  • Logging with any logger will create breadcrumbs when the Logging integration is enabled (done by default).

  • Quart: 0.16.1+
  • Python: 3.7+
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").