AIOHTTP 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.
Copied
pip install --upgrade 'sentry-sdk[aiohttp]'
Add AioHttpIntegration()
to your integrations
list:
Copied
import sentry_sdk
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
# Enable performance monitoring
enable_tracing=True,
integrations=[
AioHttpIntegration(),
],
)
Copied
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("https://sentry.io/") as response:
print("Status:", response.status)
async with session.post("http://httpbin.org/post") as response:
print("Status:", response.status)
asyncio.run(main())
This will create a transaction called testing_sentry
in the Performance section of sentry.io and will create spans for the outgoing HTTP requests.
It takes a couple of moments for the data to appear in sentry.io.
- 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").
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").
- Package:
- pypi:sentry-sdk
- Version:
- 1.45.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/