【发布时间】:2014-09-18 16:50:26
【问题描述】:
当我的数据库出现故障时,Sentry 会立即被 psycopg2 的OperationalError: could not connect to server: Connection refused 淹没。由于OperationalError 可以在无法访问的数据库之外的其他情况下抛出,所以我不能盲目地使用RAVEN_CONFIG 的IGNORE_EXCEPTIONS 忽略它。
我尝试写a filter for Django logging,但它不起作用。它正确地拦截了异常,但仍然以某种方式将其冒泡。这是过滤器:
def skip_unreachable_database(record):
"""Avoid flooding Sentry when the database is down"""
if record.exc_info:
print '>>>', record.exc_info
exc_type, exc_value = record.exc_info[:2]
if isinstance(exc_value, OperationalError) and exc_value.message.lower().startswith('could not connect to server: connection refused'):
return False
return True
有a ticket about filtering not working with Raven,但是已经关闭了。
知道如何解决这个问题吗?
【问题讨论】: