authentik/passbook/lib/sentry.py

34 lines
1.0 KiB
Python
Raw Normal View History

"""passbook sentry integration"""
2019-10-01 09:24:10 +01:00
from structlog import get_logger
LOGGER = get_logger()
def before_send(event, hint):
"""Check if error is database error, and ignore if so"""
from django_redis.exceptions import ConnectionInterrupted
from django.db import OperationalError, InternalError
from rest_framework.exceptions import APIException
from billiard.exceptions import WorkerLostError
from django.core.exceptions import DisallowedHost
from botocore.client import ClientError
2019-12-31 11:51:16 +00:00
ignored_classes = (
OperationalError,
ConnectionInterrupted,
APIException,
InternalError,
ConnectionResetError,
WorkerLostError,
DisallowedHost,
ConnectionResetError,
KeyboardInterrupt,
2019-12-31 11:51:16 +00:00
ClientError,
)
2019-12-31 11:51:16 +00:00
if "exc_info" in hint:
_exc_type, exc_value, _ = hint["exc_info"]
if isinstance(exc_value, ignored_classes):
LOGGER.info("Supressing error %r", exc_value)
return None
return event