mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-21 23:32:59 +00:00
add Report.concat(*reports)
This commit is contained in:
parent
ecffaa3d07
commit
db96082a31
3 changed files with 28 additions and 13 deletions
|
@ -1,19 +1,12 @@
|
|||
from . import metrics
|
||||
from .settings import SETTINGS
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# env parameters
|
||||
print(SETTINGS.model_dump())
|
||||
|
||||
# CPU metric
|
||||
print(metrics.cpu())
|
||||
|
||||
# MEM metric
|
||||
print(metrics.memory())
|
||||
|
||||
# DISK metric
|
||||
print(metrics.disk())
|
||||
print(metrics.Report.concat(
|
||||
metrics.cpu(),
|
||||
metrics.memory(),
|
||||
metrics.disk(),
|
||||
))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
from ._report import Report
|
||||
from .cpu import cpu
|
||||
from .disk import disk
|
||||
from .memory import memory
|
||||
|
||||
__all__ = [
|
||||
"Report",
|
||||
|
||||
"cpu",
|
||||
"disk",
|
||||
"memory",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import Callable, Iterator, Self
|
||||
from typing import Any, Callable, Iterator, Self
|
||||
|
||||
from ..settings import MetricSettings
|
||||
|
||||
|
@ -34,6 +34,25 @@ class Report:
|
|||
result: str
|
||||
failed: bool = False
|
||||
|
||||
@classmethod
|
||||
def concat(cls, *_reports: Any) -> Self:
|
||||
reports = [
|
||||
report
|
||||
for report in _reports
|
||||
if isinstance(report, Report)
|
||||
]
|
||||
|
||||
return cls(
|
||||
result=", ".join(
|
||||
report.result
|
||||
for report in reports
|
||||
),
|
||||
failed=any(
|
||||
report.failed
|
||||
for report in reports
|
||||
),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def aggregate(
|
||||
cls, *,
|
||||
|
|
Loading…
Reference in a new issue