|
|
@ -23,7 +23,7 @@ ENABLED_REASON_KEY = "enabled_reason"
|
|
|
|
TRACE_SECTION_KEY = "trace"
|
|
|
|
TRACE_SECTION_KEY = "trace"
|
|
|
|
DEFAULT_CONFIG = {
|
|
|
|
DEFAULT_CONFIG = {
|
|
|
|
ROOT_SECTION_KEY: {
|
|
|
|
ROOT_SECTION_KEY: {
|
|
|
|
NOTICE_COUNTDOWN_KEY: 10
|
|
|
|
NOTICE_COUNTDOWN_KEY: 9
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TRACE_SECTION_KEY: {},
|
|
|
|
TRACE_SECTION_KEY: {},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -42,12 +42,13 @@ class TraceConfig:
|
|
|
|
def __init__(self, config: configparser.ConfigParser) -> None:
|
|
|
|
def __init__(self, config: configparser.ConfigParser) -> None:
|
|
|
|
self._config = config
|
|
|
|
self._config = config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not self.has_enabled() or self.enabled:
|
|
|
|
|
|
|
|
self.gen_id()
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, enabled: bool, reason: Literal["AUTO", "USER"]) -> None:
|
|
|
|
def update(self, enabled: bool, reason: Literal["AUTO", "USER"]) -> None:
|
|
|
|
"""Update the config."""
|
|
|
|
"""Update the config."""
|
|
|
|
self._config[TRACE_SECTION_KEY][ENABLED_KEY] = str(enabled)
|
|
|
|
self._config[TRACE_SECTION_KEY][ENABLED_KEY] = str(enabled)
|
|
|
|
self._config[TRACE_SECTION_KEY][ENABLED_REASON_KEY] = reason
|
|
|
|
self._config[TRACE_SECTION_KEY][ENABLED_REASON_KEY] = reason
|
|
|
|
if enabled:
|
|
|
|
|
|
|
|
self.gen_id()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gen_id(self, regen=False) -> None:
|
|
|
|
def gen_id(self, regen=False) -> None:
|
|
|
|
"""[Re]generate UUIDs."""
|
|
|
|
"""[Re]generate UUIDs."""
|
|
|
@ -89,6 +90,10 @@ class TraceConfig:
|
|
|
|
"""Checks if the enabled property exists in config."""
|
|
|
|
"""Checks if the enabled property exists in config."""
|
|
|
|
return ENABLED_KEY in self._config[TRACE_SECTION_KEY]
|
|
|
|
return ENABLED_KEY in self._config[TRACE_SECTION_KEY]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def disabled(self) -> bool:
|
|
|
|
|
|
|
|
"""Checks if the enabled probperty exists and is false"""
|
|
|
|
|
|
|
|
return self.trace_config.has_enabled() and not self.trace_config.enabled
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def enabled(self) -> bool:
|
|
|
|
def enabled(self) -> bool:
|
|
|
|
"""Value of trace.enabled property in telemetry.cfg."""
|
|
|
|
"""Value of trace.enabled property in telemetry.cfg."""
|
|
|
@ -131,8 +136,7 @@ class RootConfig:
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def notice_countdown(self) -> int:
|
|
|
|
def notice_countdown(self) -> int:
|
|
|
|
"""Value for root.notice_countdown property in telemetry.cfg."""
|
|
|
|
"""Value for root.notice_countdown property in telemetry.cfg."""
|
|
|
|
|
|
|
|
return self._config[ROOT_SECTION_KEY].getint(NOTICE_COUNTDOWN_KEY, 9)
|
|
|
|
return self._config[ROOT_SECTION_KEY].getint(NOTICE_COUNTDOWN_KEY, 10)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
class Config:
|
|
|
|