asyncio
The AsyncioIntegration
integrates with applications doing concurrent code execution using Python's asyncio module.
Copied
pip install --upgrade 'sentry-sdk'
Add AsyncioIntegration()
to your list of integrations
, enable tracing and be sure to call sentry_sdk.init()
at the beginning of your async loop:
main.py
Copied
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
async def main():
sentry_sdk.init(
dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
enable_tracing=True,
integrations=[
AsyncioIntegration(),
],
)
# your code goes here.
...
asyncio.run(main())
Trigger an error in your code and see it show up in sentry.io.
main.py
Copied
import asyncio
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
async def my_task():
1/0 # raises an error!
async def main():
sentry_sdk.init(...) # same as above
asyncio.create_task(my_task())
asyncio.run(main())
- All unhandled exceptions in tasks will be captured
- Every executed Task will be instrumented and show up in the performance waterfall on Sentry.io
- 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:
- 2.0.0
- Repository:
- https://github.com/getsentry/sentry-python
- API Documentation:
- https://getsentry.github.io/sentry-python/