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