← All platforms

Sanic error tracking

Fast requests. Background tasks. The occasional surprise. Connect Sanic to the Sentry Python SDK and keep the error reports on your Telebugs server.

~/hoofnotes  pip install sentry-sdk
~/hoofnotes  nvim app.py
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from hoofnotes.web import app
@app.listener("before_server_start")
async def init_error_tracking(app):
sentry_sdk.init(
# Copy the complete DSN, key and path included.
dsn="YOUR_TELEBUGS_DSN",
integrations=[AsyncioIntegration()],
)
~/hoofnotes  sanic app:app

Space pauses or resumes. R replays. Escape shows the complete setup.

Hang on, I already use Sentry

Keep sentry-sdk and change its destination to your Telebugs DSN. Your error reports stay on your server. You don’t need a Sentry account.

Requests and background tasks?

Yes. The Sanic integration handles request exceptions; the asyncio integration adds support for task errors. Both send ordinary Python error reports to Telebugs.

Will simultaneous requests get mixed together?

The SDK keeps request scopes separate. Context added for one request stays with that request’s report, so an error isn’t described using somebody else’s request.