diff --git a/passbook/core/settings.py b/passbook/core/settings.py index d139e2ec7..f51d33cbb 100644 --- a/passbook/core/settings.py +++ b/passbook/core/settings.py @@ -24,6 +24,7 @@ from sentry_sdk.integrations.logging import LoggingIntegration from passbook import __version__ from passbook.lib.config import CONFIG +from passbook.lib.sentry import before_send VERSION = __version__ @@ -222,8 +223,7 @@ CELERY_BEAT_SCHEDULE = { if not DEBUG: sentry_init( - dsn=("https://55b5dd780bc14f4c96bba69b7a9abbcc:449af483bd0745" - "0d83be640d834e5458@sentry.services.beryju.org/8"), + dsn="https://55b5dd780bc14f4c96bba69b7a9abbcc@sentry.services.beryju.org/8", integrations=[ DjangoIntegration(), CeleryIntegration(), @@ -233,6 +233,8 @@ if not DEBUG: ) ], send_default_pii=True, + before_send=before_send, + release='p2@%s' % __version__ ) # Static files (CSS, JavaScript, Images) diff --git a/passbook/lib/sentry.py b/passbook/lib/sentry.py new file mode 100644 index 000000000..f3317b7d5 --- /dev/null +++ b/passbook/lib/sentry.py @@ -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