From c7e3d86e2d88dbaf9dfde6fe6dae3d2141969fee Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 5 Mar 2025 12:31:30 +0100 Subject: [PATCH] Revert "Enable Sentry asyncio integration (#5685)" (#5729) This essentially reverts PR #5685. The Sentry `AsyncioIntegration` replaces the asyncio task factory with its instrumentalized version, which reports all execeptions which aren't handled *within* a task to Sentry. However, we quite often run tasks and handle exceptions outside, e.g. this commen pattern (example from `MountManager` `reload()``): ```python results = await asyncio.gather( *[mount.update() for mount in mounts], return_exceptions=True ) ... create resolution issues from results with exceptions ... ``` Here, asyncio.gather() uses ensure_future(), which converts the co-routines to tasks. These Sentry instrumented tasks will then report exceptions to Sentry, even though we handle exceptions gracefully. So the `AsyncioIntegration` doesn't work for our use case, and causes unnecessary noise in Sentry. Disable it again. --- supervisor/utils/sentry.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/supervisor/utils/sentry.py b/supervisor/utils/sentry.py index 462b59a38..3be527c0e 100644 --- a/supervisor/utils/sentry.py +++ b/supervisor/utils/sentry.py @@ -8,7 +8,6 @@ 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 from sentry_sdk.integrations.atexit import AtexitIntegration from sentry_sdk.integrations.dedupe import DedupeIntegration from sentry_sdk.integrations.excepthook import ExcepthookIntegration @@ -28,6 +27,9 @@ def init_sentry(coresys: CoreSys) -> None: """Initialize sentry client.""" if not sentry_sdk.is_initialized(): _LOGGER.info("Initializing Supervisor Sentry") + # Don't use AsyncioIntegration(). We commonly handle task exceptions + # outside of tasks. This would cause exception we gracefully handle to + # be captured by sentry. sentry_sdk.init( dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612", before_send=partial(filter_data, coresys), @@ -43,7 +45,6 @@ def init_sentry(coresys: CoreSys) -> None: } ) ), - AsyncioIntegration(), ExcepthookIntegration(), DedupeIntegration(), AtexitIntegration(),