【发布时间】:2015-03-16 14:22:19
【问题描述】:
我们有一个 django 项目。我们使用 Sentry 来收集有关 HTTP 500 错误的信息。
Sentry 可以选择将事件信息添加到请求标头中,以便您可以在应用程序中处理它。
所以,我们有一个用于美味派的 mixin,看起来像这样:
class Sentry500Mixin(object):
def _handle_500(self, request, exception):
if not isinstance(exception, TastypieError) and not settings.DEBUG:
sentry_exception_handler(request=request)
data = {
'error_message': 'Sorry, this request could not be processed.',
'incident': getattr(request, 'sentry', None)
}
return self.error_response(request, data, response_class=HttpApplicationError)
else:
return super(Sentry500Mixin, self)._handle_500(request, exception)
当发生 500 错误时,我们会得到如下响应:
{"error_message": "Sorry, this request could not be processed.",
"incident": {"id": "3459b30f87ea4116a0a2855be576bbb3", "project_id": "5"}}
问题是,如果你拿着这个事件 id 去 Sentry,这个 id 很有可能不会发生任何事件。并且没有看起来像这样的事件。我确信我正在检查正确的项目,如果未创建事件,从逻辑上讲,Sentry 无法返回您的 ID,但它确实返回了。
非常感谢任何帮助和想法。谢谢。
【问题讨论】:
-
我认为 ID 是在客户端生成的:github.com/getsentry/raven-python/blob/… 你检查过你的日志记录级别,看看这个方法是否有任何错误? github.com/getsentry/raven-python/blob/…
标签: python django error-handling tastypie sentry