mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-10 00:39:22 -06:00
Add context to Sentry events during setup phase (#6308)
* Add context to Sentry events during setup phase Since not all properties are safe to access the current code avoids adding any context during initialization and setup phase. However, quite some reports are during the setup phase. This change adds some context to events during setup phase as well, to make debugging easier. * Drop default arch (not available during setup)
This commit is contained in:
parent
d85aedc42b
commit
69ae8db13c
@ -64,6 +64,19 @@ def filter_data(coresys: CoreSys, event: Event, hint: Hint) -> Event | None:
|
||||
|
||||
# Not full startup - missing information
|
||||
if coresys.core.state in (CoreState.INITIALIZE, CoreState.SETUP):
|
||||
# During SETUP, we have basic system info available for better debugging
|
||||
if coresys.core.state == CoreState.SETUP:
|
||||
event.setdefault("contexts", {}).update(
|
||||
{
|
||||
"versions": {
|
||||
"docker": coresys.docker.info.version,
|
||||
"supervisor": coresys.supervisor.version,
|
||||
},
|
||||
"host": {
|
||||
"machine": coresys.machine,
|
||||
},
|
||||
}
|
||||
)
|
||||
return event
|
||||
|
||||
# List installed addons
|
||||
|
||||
@ -115,7 +115,17 @@ async def test_not_started(coresys):
|
||||
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
||||
|
||||
await coresys.core.set_state(CoreState.SETUP)
|
||||
assert filter_data(coresys, SAMPLE_EVENT, {}) == SAMPLE_EVENT
|
||||
filtered = filter_data(coresys, SAMPLE_EVENT, {})
|
||||
# During SETUP, we should have basic system info available
|
||||
assert "contexts" in filtered
|
||||
assert "versions" in filtered["contexts"]
|
||||
assert "docker" in filtered["contexts"]["versions"]
|
||||
assert "supervisor" in filtered["contexts"]["versions"]
|
||||
assert "host" in filtered["contexts"]
|
||||
assert "machine" in filtered["contexts"]["host"]
|
||||
assert filtered["contexts"]["versions"]["docker"] == coresys.docker.info.version
|
||||
assert filtered["contexts"]["versions"]["supervisor"] == coresys.supervisor.version
|
||||
assert filtered["contexts"]["host"]["machine"] == coresys.machine
|
||||
|
||||
|
||||
async def test_defaults(coresys):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user