【发布时间】:2019-12-08 00:56:16
【问题描述】:
django 的新 sentry_sdk 提供了非常简单的安装(通过 raven 集成标记为弃用)。
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn="https://<key>@sentry.io/<project>",
integrations=[DjangoIntegration()]
)
以前,人们会像这样使用 raven 作为处理程序类来配置哨兵。
'handlers': {
'sentry': {
'level': 'ERROR', # To capture more than ERROR, change to WARNING, INFO, etc.
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
'tags': {'custom-tag': 'x'},
},
...
...
'loggers':{
'project.custom':{
'level': 'DEBUG',
'handlers': ['sentry', 'console', ,]
}
查看更多as defined here
挑战在于 raven 不接受 SENTRY_DSN 的新格式。格式为https://<key>@domain.com/project/ 旧格式类似于https://<key>:<secret>@domain.com/project。
乌鸦会抛出InvalidDSN with the old format。旧的 DSN 密钥已标记为弃用。
文档对如何定义处理程序非常沉默。显然已弃用的 raven 对新的密钥格式不满意。
我可以依赖旧的 DSN deprecated format,但会感谢有关如何使用新格式配置处理程序的建议。
【问题讨论】: