The Sanic integration adds support for the Sanic Web Framework. We support the following versions, which are known to work with the SDK:

  • 0.8
  • 18.12 LTS
  • 19.12 LTS
  • 21.3, 21.6, 21.9, 21.12 LTS
  • `22.6

* Starting with Sanic v21, sentry-sdk v1.3.0 or higher is required

The SDK will support any Sanic version of the form x.12 (LTS versions). If the latest version of Sanic is not explicitly listed here, it might not be supported.

A Python version of 3.6 or greater is also required.


Install sentry-sdk from PyPI:

pip install --upgrade sentry-sdk

If you're on Python 3.6, you also need the aiocontextvars package:

pip install --upgrade aiocontextvars


To configure the SDK, initialize it with the integration before or after your app has been initialized:

import sentry_sdk
from sentry_sdk.integrations.sanic import SanicIntegration
from sanic import Sanic


    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production,

app = Sanic(__name__)


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

  • All exceptions leading to an Internal Server Error are reported.

  • Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. 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).

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").