Skip to content

Commit

Permalink
Revert "Enable Sentry asyncio integration (#5685)" (#5729)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
agners authored Mar 5, 2025
1 parent 5d06ebe commit c7e3d86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions supervisor/utils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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
Expand All @@ -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://[email protected]/5370612",
before_send=partial(filter_data, coresys),
Expand All @@ -43,7 +45,6 @@ def init_sentry(coresys: CoreSys) -> None:
}
)
),
AsyncioIntegration(),
ExcepthookIntegration(),
DedupeIntegration(),
AtexitIntegration(),
Expand Down

0 comments on commit c7e3d86

Please sign in to comment.