getsentry / getsentry/sentry-python

Capture Loguru template

未關閉
#5,106 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Feature Integration: Loguru Logs Python
主要語言
Python
星號
2.2k
分支
669
平均合併
1 天 40 分鐘
30 天內合併 PR
212

描述

### Problem Statement

We currently don't have access to the raw message before formatting in Loguru logs so we can't add it as `sentry.message.template`.

### Solution Brainstorm

1. The most feasible way forward is getting the template from Loguru directly. Submitted a PR for that [https://github.com/Delgan/loguru/pull/1413](https://github.com/Delgan/loguru/pull/1413). This issue is mostly for internal tracking purposes and extra context.
2. The other solution would be monkeypatching the [`_log` method](https://github.com/Delgan/loguru/blob/66d6de168ba6c286a46822f3acdcdbf0225bbad0/loguru/\_logger.py#L2028) that takes care of creating the record. This would enable us to get the raw message since the method gets it as an argument. However, we don't have a way to get the formatted message afterwards: all processing happens directly in the `_log` function and nothing is returned; instead, the records are sent to the sinks directly. We could find a way to associate a raw message we've seen in the monkeypatched `_log` method with the message we receive in our sink, but that'd mean introducing some kind of book-keeping structure which I'd like to avoid. (And since Loguru's maintainer said they'd be fine with 1, we're not doing this unless anything changes.)

貢獻指南

開啟貢獻指南

研究方向

先查看連結的 Loguru PR #1413,然後檢查 issue 中連結的 Loguru `_log` 方法,以了解原始 template 是否可用。完成標準是擷取該 template,並將其以 `sentry.message.template` 的形式公開;該 issue 未提供任何 Sentry-Python 檔案或測試入口。

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

評估

技術堆疊
python
領域
observability
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
15/100

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

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