From 1355ef192d470b69026d101186c2bd3fc235bea7 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 3 Mar 2025 23:10:59 +0100 Subject: [PATCH] Exclude non-Supervisor Server Error codes from Sentry reporting (#5718) * Exclude non-Supervisor Server Error codes from Sentry reporting Exclude status codes 502 Bad Gateway and 503 Service Unavailable from Sentry aiohttp integration. These are returned by Supervisor itself when acting as a proxy for Home Assistant Core. These aren't errors of Supervisor. * ruff check --- supervisor/utils/sentry.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/supervisor/utils/sentry.py b/supervisor/utils/sentry.py index 85619b074..462b59a38 100644 --- a/supervisor/utils/sentry.py +++ b/supervisor/utils/sentry.py @@ -5,6 +5,7 @@ from functools import partial import logging from typing import Any +from aiohttp.web_exceptions import HTTPBadGateway, HTTPServiceUnavailable import sentry_sdk from sentry_sdk.integrations.aiohttp import AioHttpIntegration from sentry_sdk.integrations.asyncio import AsyncioIntegration @@ -33,7 +34,15 @@ def init_sentry(coresys: CoreSys) -> None: auto_enabling_integrations=False, default_integrations=False, integrations=[ - AioHttpIntegration(), + AioHttpIntegration( + failed_request_status_codes=frozenset(range(500, 600)) + - set( + { + HTTPBadGateway.status_code, + HTTPServiceUnavailable.status_code, + } + ) + ), AsyncioIntegration(), ExcepthookIntegration(), DedupeIntegration(),