Fix sentry spam (#2313)

This commit is contained in:
Pascal Vizeli 2020-11-30 11:01:10 +01:00 committed by GitHub
parent 19620d6808
commit 49853e92a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View File

@ -303,7 +303,6 @@ def setup_diagnostics(coresys: CoreSys) -> None:
sentry_sdk.init(
dsn="https://9c6ea70f49234442b4746e447b24747e@o427061.ingest.sentry.io/5370612",
before_send=lambda event, hint: filter_data(coresys, event, hint),
auto_enabling_integrations=False,
integrations=[AioHttpIntegration(), sentry_logging],
release=SUPERVISOR_VERSION,
max_breadcrumbs=30,

View File

@ -76,6 +76,10 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
},
"resolution": {
"issues": [attr.asdict(issue) for issue in coresys.resolution.issues],
"suggestions": [
attr.asdict(suggestion)
for suggestion in coresys.resolution.suggestions
],
"unhealthy": coresys.resolution.unhealthy,
},
}

View File

@ -10,6 +10,7 @@ from supervisor.misc.filter import filter_data
from supervisor.resolution.const import (
ContextType,
IssueType,
SuggestionType,
UnhealthyReason,
UnsupportedReason,
)
@ -124,6 +125,34 @@ def test_issues_on_report(coresys):
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):
"""Attach unhealthy to report."""