Learn about the AIOHTTP integration and how it adds support for the AIOHTTP HTTP client.

The AIOHTTP integration instruments outgoing HTTP requests using the AIOHTTP client.

Use this integration to create spans for outgoing requests and ensure traces are properly propagated to downstream services.

This integration also supports AIOHTTP servers. See AIOHTTP server documentation for details.

Install sentry-sdk from PyPI with the aiohttp extra.

pip install --upgrade 'sentry-sdk[aiohttp]'

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

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

import sentry_sdk

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.

import asyncio
import aiohttp

async def main():
    sentry_sdk.init(...)  # same as above

    with sentry_sdk.start_transaction(name="testing_sentry"):
        async with aiohttp.ClientSession() as session:
            async with session.get("") as response:
                print("Status:", response.status)
            async with"") as response:
                print("Status:", response.status)

This will create a transaction called testing_sentry in the Performance section of and will create spans for the outgoing HTTP requests.

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

  • 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").