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 . import metrics
|
||||||
from .settings import SETTINGS
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
# env parameters
|
print(metrics.Report.concat(
|
||||||
print(SETTINGS.model_dump())
|
metrics.cpu(),
|
||||||
|
metrics.memory(),
|
||||||
# CPU metric
|
metrics.disk(),
|
||||||
print(metrics.cpu())
|
))
|
||||||
|
|
||||||
# MEM metric
|
|
||||||
print(metrics.memory())
|
|
||||||
|
|
||||||
# DISK metric
|
|
||||||
print(metrics.disk())
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
from ._report import Report
|
||||||
from .cpu import cpu
|
from .cpu import cpu
|
||||||
from .disk import disk
|
from .disk import disk
|
||||||
from .memory import memory
|
from .memory import memory
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
"Report",
|
||||||
|
|
||||||
"cpu",
|
"cpu",
|
||||||
"disk",
|
"disk",
|
||||||
"memory",
|
"memory",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Callable, Iterator, Self
|
from typing import Any, Callable, Iterator, Self
|
||||||
|
|
||||||
from ..settings import MetricSettings
|
from ..settings import MetricSettings
|
||||||
|
|
||||||
|
@ -34,6 +34,25 @@ class Report:
|
||||||
result: str
|
result: str
|
||||||
failed: bool = False
|
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
|
@classmethod
|
||||||
def aggregate(
|
def aggregate(
|
||||||
cls, *,
|
cls, *,
|
||||||
|
|
Loading…
Reference in a new issue