Enable Sentry asyncio integration (#5685)

Enable the Sentry asyncio integration. This makes sure that exception
in non-awaited tasks get reported to sentry.

While at it, use partial instead of lambda for the filter function.
This commit is contained in:
Stefan Agner 2025-02-28 09:57:11 +01:00 committed by GitHub
parent 2274de969f
commit 362bd8fd21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,12 @@
"""Utilities for sentry."""
from functools import partial
import logging
from typing import Any
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
@ -26,11 +28,12 @@ def init_sentry(coresys: CoreSys) -> None:
_LOGGER.info("Initializing Supervisor Sentry")
sentry_sdk.init(
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
before_send=lambda event, hint: filter_data(coresys, event, hint),
before_send=partial(filter_data, coresys),
auto_enabling_integrations=False,
default_integrations=False,
integrations=[
AioHttpIntegration(),
AsyncioIntegration(),
ExcepthookIntegration(),
DedupeIntegration(),
AtexitIntegration(),