Sentry send env infos (#1992)

This commit is contained in:
Pascal Vizeli 2020-08-29 11:44:08 +02:00 committed by GitHub
parent 58b88a6919
commit a9a2c35f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,8 @@ def filter_data(coresys: CoreSys, event: dict, hint: dict) -> dict:
if not coresys.config.diagnostics or not coresys.core.supported or dev_env: if not coresys.config.diagnostics or not coresys.core.supported or dev_env:
return None return None
event.setdefault("extra", {}).update({"os.environ": dict(os.environ)})
# Not full startup - missing information # Not full startup - missing information
if coresys.core.state in (CoreState.INITIALIZE, CoreState.SETUP): if coresys.core.state in (CoreState.INITIALIZE, CoreState.SETUP):
return event return event

View File

@ -1,11 +1,21 @@
"""Test sentry data filter.""" """Test sentry data filter."""
import os
from unittest.mock import patch from unittest.mock import patch
import pytest
from supervisor.const import SUPERVISOR_VERSION, CoreState from supervisor.const import SUPERVISOR_VERSION, CoreState
from supervisor.exceptions import AddonConfigurationError from supervisor.exceptions import AddonConfigurationError
from supervisor.misc.filter import filter_data from supervisor.misc.filter import filter_data
SAMPLE_EVENT = {"sample": "event"} SAMPLE_EVENT = {"sample": "event", "extra": {"Test": "123"}}
@pytest.fixture
def sys_env(autouse=True):
"""Fixture to inject hassio env."""
with patch.dict(os.environ, {"Test": "123"}):
yield
def test_ignored_exception(coresys): def test_ignored_exception(coresys):