什么是推荐的扭曲哨兵/乌鸦整合?

时间:2013-09-27 21:24:54

标签: twisted sentry raven

raven有很多集成,包括python日志记录。一方面,twisted不使用python的日志记录。而在另一方面,没有直接整合乌鸦的扭曲。

那么目前在基于扭曲的设置中使用raven的最佳做法是什么?

3 个答案:

答案 0 :(得分:10)

如果存在异常活动,则只能在没有参数的情况下调用

raven的{​​{1}},而在调用日志观察者时并非总是如此。因此,将异常信息从记录的captureException中拉出来:

Failure

答案 1 :(得分:2)

user1252307答案是一个很好的开始,但在哨兵方面,你得到一个相对无益的字典,没有堆栈跟踪。

如果您正在尝试查看和追踪意外异常,请尝试对log_sentry函数进行此小改动:

from twisted.python import log
from raven import Client

client = Client(dsn='twisted+http://YOUR_DSN_HERE')

def log_sentry(dictionary):
    if dictionary.get('isError'):
        if 'failure' in dictionary:
            client.captureException() # Send the current exception info to Sentry.
        else:
            #format the dictionary in whatever way you want
            client.captureMessage(dictionary)

log.addObserver(log_sentry)

可能有更好的方法来过滤基于非异常的错误消息,这可能会尝试发出在存在非异常故障的情况下不存在的异常信息。

答案 2 :(得分:1)

from twisted.python import log
from raven import Client

client = Client(dsn='twisted+http://YOUR_DSN_HERE')

def log_sentry(dictionary):
    if dictionary.get('isError'):
        #format the dictionary in whatever way you want
        client.captureMessage(dictionary)

log.addObserver(log_sentry)
相关问题