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 天 40 分鐘
30 天內合併 PR
212

描述

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?

貢獻指南

開啟貢獻指南

研究方向

先閱讀現有的 AsyncioIntegration 及其隔離作用域行為,然後比較提議的自動啟用設計。檢查如何對正在執行的事件迴圈進行修補、是否可以重複修補,以及這會如何影響現有的 AsyncioIntegration 使用者。完成的標準是任務隔離能夠自動運作,同時附加功能仍需明確 opt-in,並且在沒有事件迴圈的情況下能夠優雅地失敗。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
backend
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。