From 0a63ca46ed3d6b4005d529e4fe93bd71dabdff03 Mon Sep 17 00:00:00 2001 From: Dhruv Bhanushali Date: Tue, 23 Jul 2024 10:35:28 +0400 Subject: [PATCH] Use a separate logger for dead links check that Sentry will ignore (#4649) --- api/api/utils/check_dead_links/__init__.py | 4 ++-- api/conf/settings/sentry.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/api/utils/check_dead_links/__init__.py b/api/api/utils/check_dead_links/__init__.py index f9abc9de4a0..ef602d5b692 100644 --- a/api/api/utils/check_dead_links/__init__.py +++ b/api/api/utils/check_dead_links/__init__.py @@ -17,7 +17,7 @@ logger = structlog.get_logger(__name__) - +head_logger = structlog.get_logger(f"{__name__}._head") CACHE_PREFIX = "valid:" HEADERS = { @@ -57,7 +57,7 @@ async def _head( status = response.status except (aiohttp.ClientError, asyncio.TimeoutError) as exception: if not isinstance(exception, asyncio.TimeoutError): - logger.error("dead_link_validation_error", e=exception) + head_logger.error("dead_link_validation_error", e=exception) status = _ERROR_STATUS else: status = _TIMEOUT_STATUS diff --git a/api/conf/settings/sentry.py b/api/conf/settings/sentry.py index 64130786103..428eb6dee38 100644 --- a/api/conf/settings/sentry.py +++ b/api/conf/settings/sentry.py @@ -30,3 +30,6 @@ # code, which can be registered by Sentry and obscure the underlying reason # why 5xx response was returned in the first place. ignore_logger("django_structlog.middlewares.request") + # These errors can occur in large volumes and so we don't want them to fill + # up in Sentry and overwhelm us with Slack notifications. + ignore_logger("api.utils.check_dead_links._head")