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

How do I increase the max length of captured Python parameters in Sentry?

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

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

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

sentry_sdk.init(
    dsn="sentry dsn",
    integrations=[DjangoIntegration()],
    send_default_pii=True
)

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

# TODO: read max_length from config

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

我刚刚在 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

after sentry_sdk.init 按预期工作(哨兵网络客户端显示整个错误消息,而不是前 512 个字符后的 ...)。

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