From ae64817b15657972c2f1fe6dda1a4720126b9892 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 1 Jul 2024 12:26:12 +0200 Subject: [PATCH] Add filter for main already-caught pika errors These are already caught by Dramatiq, and retried --- greenweb/settings/production.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/greenweb/settings/production.py b/greenweb/settings/production.py index 474f71cb..dcf28536 100644 --- a/greenweb/settings/production.py +++ b/greenweb/settings/production.py @@ -58,6 +58,23 @@ # https://docs.sentry.io/platforms/python/guides/django/performance/ sentry_sample_rate = os.environ.get("SENTRY_SAMPLE_RATE", 0) # noqa + +def filter_sentry(event, hint): + """ + Filter out noisy errors from pika, the underlying + rabbitmq library that we know are caught by Dramatiq and retried + """ + + if 'logger' in event and event['logger'] in [ + 'pika.adapters.blocking_connection', + 'pika.adapters.base_connection', + 'pika.adapters.utils.io_services_utils' + ]: + return None + + return event + + if SENTRY_DSN: sentry_sdk.init( # set our identifying credentials @@ -72,6 +89,7 @@ # to see who is having a bad day, so we can contact them and # at least apologise about the broken site send_default_pii=True, + before_send=filter_sentry, )