sentry-python
sentry-python copied to clipboard
Support/document initializing SDK when a third-party library controls the asyncio event loop
Problem Statement
User reported via ZD ticket: Some frameworks (in this case LiveKit agents) create and manage their own asyncio event loop internally. Users can only access the async entrypoint after the loop is already set up by the framework. This prevents calling sentry_sdk.init(..., integrations=[AsyncioIntegration()]) early enough to capture errors in synchronous startup code or in the main process that runs before the loop is created. Current workarounds initialize Sentry without AsyncioIntegration, flush/close, and re-init inside the async entrypoint, but double init is unsupported and adds startup latency.
Solution Brainstorm
Provide a supported or document how users should handle this case.