如何增加 Sentry 中捕获的 Python 参数的最大长度?

Nat*_*nes 7 python django sentry

sentry-python==0.5.3在 Django1.11.6项目中使用,当我检查...堆栈跟踪的参数列表时,我看到一些值足够长,可以被省略号截断。我想看到整个价值。

如何配置sentry-python以在堆栈跟踪中显示整个参数值?

这是我init在 Django 配置中调用该函数的方式:

sentry_sdk.init(
    dsn="sentry dsn",
    integrations=[DjangoIntegration()],
    send_default_pii=True
)
Run Code Online (Sandbox Code Playgroud)

use*_*747 11

我刚刚在 sentry-sdk python 源代码中发现了这个:https : //github.com/getsentry/sentry-python/blob/0.12.2/sentry_sdk/utils.py#L36

确实:

sentry_sdk.utils.MAX_STRING_LENGTH = 8192 # undocumented truncation length as of v0.12.2
Run Code Online (Sandbox Code Playgroud)

aftersentry_sdk.init按预期工作(哨兵 Web 客户端显示整个错误消息,而不是...在前 512 个字符之后)。

请注意,正如@Markus Unterwaditzer 所提到的,哨兵的服务器可能仍会进行一些截断,但我没有遇到过长度为 5000 个字符左右的错误消息。希望堆栈跟踪和面包屑在错误消息本身之前被截断。


Nat*_*nes 3

我刚刚在sentry-sdk Python源代码中发现了这个,这让我觉得在新的SDK中还不可能配置这个。

# TODO: read max_length from config
Run Code Online (Sandbox Code Playgroud)

https://github.com/getsentry/sentry-python/blob/9f15a4027615d40cfdb37375233bc903d3cc753e/sentry_sdk/utils.py#L626