Learn about using Sentry with AIOHTTP.

The AIOHTTP integration adds support for the AIOHTTP server web framework.

If you use AIOHTTP as your HTTP client and want to instrument outgoing HTTP requests, have a look at the AIOHTTP client documentation.

Install sentry-sdk from PyPI with the aiohttp extra:

pip install --upgrade sentry-sdk[aiohttp]

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

pip install --upgrade aiocontextvars

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

from aiohttp import web

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

async def hello(request):
    1 / 0  # raises an error
    return web.Response(text="Hello, world")

app = web.Application()
app.add_routes([web.get('/', hello)])


When you point your browser to http://localhost:8080/ a transaction will be created in the Performance section of Additionally, an error event will be sent to and will be connected to the transaction.

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

  • The Sentry Python SDK will install the AIOHTTP integration for all of your apps.
  • All exceptions leading to an Internal Server Error are reported.
  • The AIOHTTP integration currently does not attach the request body, see GitHub issue.
  • Logging with any logger will create breadcrumbs when the Logging integration is enabled (done by default).

By adding AioHttpIntegration to your sentry_sdk.init() call explicitly, you can set options for AioHttpIntegration to change its behavior:

import sentry_sdk
from sentry_sdk.integrations.aiohttp import AioHttpIntegration

    # same as above

You can pass the following keyword arguments to AioHttpIntegration():

Configure the way Sentry names transactions:

  • GET /path/{id} if you set transaction_style="method_and_path_pattern"
  • <module_name>.hello if you set transaction_style="handler_name"

The default is "handler_name".

  • AIOHTTP: 3.5+
  • 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").