mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 15:16:33 +00:00
Fix sentry spam (#2313)
This commit is contained in:
parent
19620d6808
commit
49853e92a4
@ -303,7 +303,6 @@ def setup_diagnostics(coresys: CoreSys) -> None:
|
|||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
|
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
|
||||||
before_send=lambda event, hint: filter_data(coresys, event, hint),
|
before_send=lambda event, hint: filter_data(coresys, event, hint),
|
||||||
auto_enabling_integrations=False,
|
|
||||||
integrations=[AioHttpIntegration(), sentry_logging],
|
integrations=[AioHttpIntegration(), sentry_logging],
|
||||||
release=SUPERVISOR_VERSION,
|
release=SUPERVISOR_VERSION,
|
||||||
max_breadcrumbs=30,
|
max_breadcrumbs=30,
|
||||||
|
@ -76,6 +76,10 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
|
|||||||
},
|
},
|
||||||
"resolution": {
|
"resolution": {
|
||||||
"issues": [attr.asdict(issue) for issue in coresys.resolution.issues],
|
"issues": [attr.asdict(issue) for issue in coresys.resolution.issues],
|
||||||
|
"suggestions": [
|
||||||
|
attr.asdict(suggestion)
|
||||||
|
for suggestion in coresys.resolution.suggestions
|
||||||
|
],
|
||||||
"unhealthy": coresys.resolution.unhealthy,
|
"unhealthy": coresys.resolution.unhealthy,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ from supervisor.misc.filter import filter_data
|
|||||||
from supervisor.resolution.const import (
|
from supervisor.resolution.const import (
|
||||||
ContextType,
|
ContextType,
|
||||||
IssueType,
|
IssueType,
|
||||||
|
SuggestionType,
|
||||||
UnhealthyReason,
|
UnhealthyReason,
|
||||||
UnsupportedReason,
|
UnsupportedReason,
|
||||||
)
|
)
|
||||||
@ -124,6 +125,34 @@ def test_issues_on_report(coresys):
|
|||||||
assert event["contexts"]["resolution"]["issues"][0]["context"] == ContextType.SYSTEM
|
assert event["contexts"]["resolution"]["issues"][0]["context"] == ContextType.SYSTEM
|
||||||
|
|
||||||
|
|
||||||
|
def test_suggestions_on_report(coresys):
|
||||||
|
"""Attach suggestion to report."""
|
||||||
|
|
||||||
|
coresys.resolution.create_issue(
|
||||||
|
IssueType.FATAL_ERROR,
|
||||||
|
ContextType.SYSTEM,
|
||||||
|
suggestions=[SuggestionType.EXECUTE_RELOAD],
|
||||||
|
)
|
||||||
|
|
||||||
|
coresys.config.diagnostics = True
|
||||||
|
coresys.core.state = CoreState.RUNNING
|
||||||
|
|
||||||
|
with patch("shutil.disk_usage", return_value=(42, 42, 2 * (1024.0 ** 3))):
|
||||||
|
event = filter_data(coresys, SAMPLE_EVENT, {})
|
||||||
|
|
||||||
|
assert "issues" in event["contexts"]["resolution"]
|
||||||
|
assert event["contexts"]["resolution"]["issues"][0]["type"] == IssueType.FATAL_ERROR
|
||||||
|
assert event["contexts"]["resolution"]["issues"][0]["context"] == ContextType.SYSTEM
|
||||||
|
assert (
|
||||||
|
event["contexts"]["resolution"]["suggestions"][0]["type"]
|
||||||
|
== SuggestionType.EXECUTE_RELOAD
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
event["contexts"]["resolution"]["suggestions"][0]["context"]
|
||||||
|
== ContextType.SYSTEM
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_unhealthy_on_report(coresys):
|
def test_unhealthy_on_report(coresys):
|
||||||
"""Attach unhealthy to report."""
|
"""Attach unhealthy to report."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user