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:
Joakim Sørensen 2020-08-15 16:26:01 +02:00 committed by GitHub
parent 620234e708
commit b6509dca1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 13 deletions

View File

@ -38,25 +38,39 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
if coresys.core.state in (CoreStates.INITIALIZE, CoreStates.SETUP):
return event
# List installed addons
installed_addons = [
{"slug": addon.slug, "repository": addon.repository, "name": addon.name}
for addon in coresys.addons.installed
]
# Update information
event.setdefault("extra", {}).update(
event.setdefault("contexts", {}).update(
{
"supervisor": {
"machine": coresys.machine,
"arch": coresys.arch.default,
"docker": coresys.docker.info.version,
"channel": coresys.updater.channel,
"supervisor": coresys.supervisor.version,
"os": coresys.hassos.version,
"installed_addons": installed_addons,
"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,
"kernel": coresys.host.info.kernel,
"core": coresys.homeassistant.version,
"machine": coresys.machine,
},
"versions": {
"audio": coresys.plugins.audio.version,
"dns": coresys.plugins.dns.version,
"multicast": coresys.plugins.multicast.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(

View File

@ -1,7 +1,7 @@
"""Test sentry data filter."""
from unittest.mock import patch
from supervisor.const import CoreStates
from supervisor.const import SUPERVISOR_VERSION, CoreStates
from supervisor.exceptions import AddonConfigurationError
from supervisor.misc.filter import filter_data
@ -58,7 +58,8 @@ def test_defaults(coresys):
filtered = filter_data(coresys, SAMPLE_EVENT, {})
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):