getsentry / getsentry/sentry-python

Auto-isolate asyncio tasks if event loop is running

未关闭
#5,379 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Better Async Support Improvement Integration: Asyncio Python
主要语言
Python
星标
2.2k
派生
669
平均合并
1 天 1 小时
30 天内合并 PR
213

描述

Currently, the opt-in `AsyncioIntegration` is responsible for multiple things, one of them being providing proper scope isolation in asyncio tasks. Without this functionality, people are running into different types of hard-to-diagnose scope bleed issues, like [here](https://github.com/getsentry/sentry-python/issues/5352).

### Goal
- Automatically patch the current event loop to isolate tasks in their isolation scopes, if there is an event loop running
- For additional functionality (creating task spans, etc.), explicit opt-in should still be required from users

### How to do this

Different ways to do this, each with its own caveats (e.g. introducing breaking changes).

1. Take the isolation scope logic out of `AsyncioIntegration` into its own integration and make it auto-enabled (best effort, if there is no event loop we can't do anything).
2. Make `AsyncioIntegration` auto-enabled, and change the additional functions it's providing (like task spans) to be opt-in. Also, make it fail gracefully if there is no event loop to patch.
3. ???

When picking an option, consider:
- Will this break behavior for existing users using the `AsyncioIntegration`?
- Is there a risk of double-patching the event loop?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。