Use Sentry helper function to report warnings (#5734)

* Use Sentry helper function to report warnings

Don't use Sentry directly but the existing helper function.

* Add pytest that Sentry is by default off

* Address ruff

* Address ruff
This commit is contained in:
Stefan Agner 2025-03-06 23:45:48 +01:00 committed by GitHub
parent 6ef4f3cc67
commit a2b8df0a6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -8,7 +8,6 @@ import signal
import warnings import warnings
from colorlog import ColoredFormatter from colorlog import ColoredFormatter
from sentry_sdk import capture_exception
from .addons.manager import AddonManager from .addons.manager import AddonManager
from .api import RestAPI from .api import RestAPI
@ -46,7 +45,7 @@ from .services import ServiceManager
from .store import StoreManager from .store import StoreManager
from .supervisor import Supervisor from .supervisor import Supervisor
from .updater import Updater from .updater import Updater
from .utils.sentry import init_sentry from .utils.sentry import capture_exception, init_sentry
_LOGGER: logging.Logger = logging.getLogger(__name__) _LOGGER: logging.Logger = logging.getLogger(__name__)

View File

@ -0,0 +1,15 @@
"""Unit tests for Sentry."""
from unittest.mock import patch
from supervisor.bootstrap import initialize_coresys
async def test_sentry_disabled_by_default(supervisor_name):
"""Test diagnostics off by default."""
with (
patch("supervisor.bootstrap.initialize_system"),
patch("sentry_sdk.init") as sentry_init,
):
await initialize_coresys()
sentry_init.assert_not_called()