mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-24 08:23:01 +00:00
Settings.separator
This commit is contained in:
parent
5b151beb7f
commit
862e78eec0
3 changed files with 9 additions and 5 deletions
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
|
@ -10,7 +10,7 @@
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "kiwi_simple_metrics.main",
|
"module": "kiwi_simple_metrics.main",
|
||||||
"env": {
|
"env": {
|
||||||
"METRIC_DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
|
"METRIC__DISK__PATHS": "[\"/var\", \"/\", \"/dev\"]",
|
||||||
},
|
},
|
||||||
"justMyCode": true
|
"justMyCode": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Callable, Iterator, Self
|
from typing import Any, Callable, Iterator, Self
|
||||||
|
|
||||||
from ..settings import MetricSettings
|
from ..settings import SETTINGS, MetricSettings
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True, kw_only=True)
|
@dataclass(slots=True, kw_only=True)
|
||||||
|
@ -43,7 +43,7 @@ class Report:
|
||||||
]
|
]
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
result=", ".join(
|
result=SETTINGS.separator.join(
|
||||||
report.result
|
report.result
|
||||||
for report in reports
|
for report in reports
|
||||||
),
|
),
|
||||||
|
@ -70,7 +70,7 @@ class Report:
|
||||||
return cls(
|
return cls(
|
||||||
result=settings.report_outer.format(
|
result=settings.report_outer.format(
|
||||||
name=settings.name,
|
name=settings.name,
|
||||||
inner=", ".join(
|
inner=SETTINGS.separator.join(
|
||||||
report.result
|
report.result
|
||||||
for report in reports[:settings.count]
|
for report in reports[:settings.count]
|
||||||
),
|
),
|
||||||
|
|
|
@ -84,10 +84,14 @@ class DiskMS(MetricSettings):
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(
|
||||||
env_prefix="METRIC_",
|
env_prefix="METRIC__",
|
||||||
env_nested_delimiter="__",
|
env_nested_delimiter="__",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# separates metrics and values in reports
|
||||||
|
separator: str = ", "
|
||||||
|
|
||||||
|
# metrics settings
|
||||||
cpu: CpuMS = CpuMS()
|
cpu: CpuMS = CpuMS()
|
||||||
memory: MemoryMS = MemoryMS()
|
memory: MemoryMS = MemoryMS()
|
||||||
disk: DiskMS = DiskMS()
|
disk: DiskMS = DiskMS()
|
||||||
|
|
Loading…
Reference in a new issue