diff --git a/src/platforms/python/guides/sanic/index.mdx b/src/platforms/python/guides/sanic/index.mdx index 125ed9f6b7f7e..108131e644fc6 100644 --- a/src/platforms/python/guides/sanic/index.mdx +++ b/src/platforms/python/guides/sanic/index.mdx @@ -5,26 +5,14 @@ redirect_from: description: "Learn about using Sentry with Sanic." --- -The Sanic integration adds support for the [Sanic Web Framework](https://sanicframework.org). 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. +The Sanic integration adds support for the [Sanic Web Framework](https://sanic.dev/). ## Install -Install `sentry-sdk` from PyPI: +Install `sentry-sdk` from PyPI with the `sanic` extra: ```bash -pip install --upgrade sentry-sdk +pip install --upgrade sentry-sdk[sanic] ``` If you're on Python 3.6, you also need the `aiocontextvars` package: @@ -35,30 +23,42 @@ pip install --upgrade aiocontextvars ## Configure -To configure the SDK, initialize it with the integration before or after your app has been initialized: +If you have the `sanic` package in your dependencies, the Bottle integration will be enabled automatically when you initialize the Sentry SDK. ```python -import sentry_sdk -from sentry_sdk.integrations.sanic import SanicIntegration from sanic import Sanic +import sentry_sdk sentry_sdk.init( dsn="___PUBLIC_DSN___", - integrations=[ - SanicIntegration(), - ], - # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. - # We recommend adjusting this value in production, traces_sample_rate=1.0, ) app = Sanic(__name__) ``` +## Verify + +```python +from sanic import Sanic +from sanic.response import text + +sentry_sdk.init(...) # same as above + +app = Sanic(__name__) + +@app.get("/") +async def hello_world(request): + 1 / 0 # raises an error + return text("Hello, world.")` +``` + +When you point your browser to [http://localhost:8000/](http://localhost:8000/) an error event will be sent to [sentry.io](https://sentry.io). + ## Behavior - The Sentry Python SDK will install the Sanic integration for all of your apps. @@ -72,3 +72,8 @@ app = Sanic(__name__) - Logging with any logger will create breadcrumbs when the [Logging](/platforms/python/guides/logging/) integration is enabled (done by default). + +## Supported Versions + +- Sanic: 0.8+ +- Python: 3.6+ (Sanic 0.8+), 3.7+ (Sanic 21.0+)