Settings.separator

This commit is contained in:
Jörn-Michael Miehe 2023-08-31 22:25:18 +00:00
parent 5b151beb7f
commit 862e78eec0
3 changed files with 9 additions and 5 deletions

2
.vscode/launch.json vendored
View file

@ -10,7 +10,7 @@
"request": "launch",
"module": "kiwi_simple_metrics.main",
"env": {
"METRIC_DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
"METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
},
"justMyCode": true
}

View file

@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import Any, Callable, Iterator, Self
from ..settings import MetricSettings
from ..settings import SETTINGS, MetricSettings
@dataclass(slots=True, kw_only=True)
@ -43,7 +43,7 @@ class Report:
]
return cls(
result=", ".join(
result=SETTINGS.separator.join(
report.result
for report in reports
),
@ -70,7 +70,7 @@ class Report:
return cls(
result=settings.report_outer.format(
name=settings.name,
inner=", ".join(
inner=SETTINGS.separator.join(
report.result
for report in reports[:settings.count]
),

View file

@ -84,10 +84,14 @@ class DiskMS(MetricSettings):
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_prefix="METRIC_",
env_prefix="METRIC__",
env_nested_delimiter="__",
)
# separates metrics and values in reports
separator: str = ", "
# metrics settings
cpu: CpuMS = CpuMS()
memory: MemoryMS = MemoryMS()
disk: DiskMS = DiskMS()