filter out connection errors for sentry

This commit is contained in:
Jens Langhammer
2019-04-29 19:16:49 +02:00
parent 57de6cbafc
commit cb3732cb2b
2 changed files with 21 additions and 2 deletions

17
passbook/lib/sentry.py Normal file
View File

@ -0,0 +1,17 @@
"""passbook sentry integration"""
def before_send(event, hint):
"""Check if error is database error, and ignore if so"""
from django.core.exceptions import OperationalError
from django_redis.exceptions import ConnectionInterrupted
ignored_classes = [
OperationalError,
ConnectionInterrupted,
]
if 'exc_info' in hint:
_exc_type, exc_value, _ = hint['exc_info']
if isinstance(exc_value, ignored_classes):
return None
return event