mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +00:00
Split extra info and add more metrics (#1927)
* Split extra * Restructure and add info * adjust test * Move docker version * Add name and repository for addons * Test supervisor version * Use context instead of extra * adjust test
This commit is contained in:
parent
620234e708
commit
b6509dca1f
@ -38,25 +38,39 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
|
|||||||
if coresys.core.state in (CoreStates.INITIALIZE, CoreStates.SETUP):
|
if coresys.core.state in (CoreStates.INITIALIZE, CoreStates.SETUP):
|
||||||
return event
|
return event
|
||||||
|
|
||||||
|
# List installed addons
|
||||||
|
installed_addons = [
|
||||||
|
{"slug": addon.slug, "repository": addon.repository, "name": addon.name}
|
||||||
|
for addon in coresys.addons.installed
|
||||||
|
]
|
||||||
|
|
||||||
# Update information
|
# Update information
|
||||||
event.setdefault("extra", {}).update(
|
event.setdefault("contexts", {}).update(
|
||||||
{
|
{
|
||||||
"supervisor": {
|
"supervisor": {
|
||||||
"machine": coresys.machine,
|
|
||||||
"arch": coresys.arch.default,
|
|
||||||
"docker": coresys.docker.info.version,
|
|
||||||
"channel": coresys.updater.channel,
|
"channel": coresys.updater.channel,
|
||||||
"supervisor": coresys.supervisor.version,
|
"installed_addons": installed_addons,
|
||||||
"os": coresys.hassos.version,
|
"repositories": coresys.config.addons_repositories,
|
||||||
|
},
|
||||||
|
"host": {
|
||||||
|
"arch": coresys.arch.default,
|
||||||
|
"board": coresys.hassos.board,
|
||||||
|
"deployment": coresys.host.info.deployment,
|
||||||
|
"disk_free_space": coresys.host.info.free_space,
|
||||||
"host": coresys.host.info.operating_system,
|
"host": coresys.host.info.operating_system,
|
||||||
"kernel": coresys.host.info.kernel,
|
"kernel": coresys.host.info.kernel,
|
||||||
"core": coresys.homeassistant.version,
|
"machine": coresys.machine,
|
||||||
|
},
|
||||||
|
"versions": {
|
||||||
"audio": coresys.plugins.audio.version,
|
"audio": coresys.plugins.audio.version,
|
||||||
"dns": coresys.plugins.dns.version,
|
|
||||||
"multicast": coresys.plugins.multicast.version,
|
|
||||||
"cli": coresys.plugins.cli.version,
|
"cli": coresys.plugins.cli.version,
|
||||||
"disk_free_space": coresys.host.info.free_space,
|
"core": coresys.homeassistant.version,
|
||||||
}
|
"dns": coresys.plugins.dns.version,
|
||||||
|
"docker": coresys.docker.info.version,
|
||||||
|
"multicast": coresys.plugins.multicast.version,
|
||||||
|
"os": coresys.hassos.version,
|
||||||
|
"supervisor": coresys.supervisor.version,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
event.setdefault("tags", []).extend(
|
event.setdefault("tags", []).extend(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Test sentry data filter."""
|
"""Test sentry data filter."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from supervisor.const import CoreStates
|
from supervisor.const import SUPERVISOR_VERSION, CoreStates
|
||||||
from supervisor.exceptions import AddonConfigurationError
|
from supervisor.exceptions import AddonConfigurationError
|
||||||
from supervisor.misc.filter import filter_data
|
from supervisor.misc.filter import filter_data
|
||||||
|
|
||||||
@ -58,7 +58,8 @@ def test_defaults(coresys):
|
|||||||
filtered = filter_data(coresys, SAMPLE_EVENT, {})
|
filtered = filter_data(coresys, SAMPLE_EVENT, {})
|
||||||
|
|
||||||
assert ["installation_type", "supervised"] in filtered["tags"]
|
assert ["installation_type", "supervised"] in filtered["tags"]
|
||||||
assert filtered["extra"]["supervisor"]["arch"] == "amd64"
|
assert filtered["contexts"]["host"]["arch"] == "amd64"
|
||||||
|
assert filtered["contexts"]["versions"]["supervisor"] == SUPERVISOR_VERSION
|
||||||
|
|
||||||
|
|
||||||
def test_sanitize(coresys):
|
def test_sanitize(coresys):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user