diff --git a/kiwi_simple_metrics/main.py b/kiwi_simple_metrics/main.py index 2c0dba5..7d1b3f4 100644 --- a/kiwi_simple_metrics/main.py +++ b/kiwi_simple_metrics/main.py @@ -44,15 +44,17 @@ def run_metrics( async def async_main_loop() -> None: loop = asyncio.get_running_loop() - while True: - with concurrent.futures.ThreadPoolExecutor( - max_workers=SETTINGS.threads, - ) as pool: + with concurrent.futures.ThreadPoolExecutor( + max_workers=SETTINGS.threads, + ) as pool: + while True: + # start interval and metrics at the same time await asyncio.gather( asyncio.sleep(SETTINGS.interval), loop.run_in_executor( None, run_metrics, pool, + # metrics are reported in this order metrics.cpu, metrics.memory, metrics.disk, diff --git a/kiwi_simple_metrics/settings/metric.py b/kiwi_simple_metrics/settings/metric.py index 49e1b23..d1b5b68 100644 --- a/kiwi_simple_metrics/settings/metric.py +++ b/kiwi_simple_metrics/settings/metric.py @@ -93,3 +93,9 @@ class ExternalMS(MetricSettings): # wait at most this many seconds for each executable timeout: int = 60 + + @field_validator("count", mode="after") + @classmethod + def force_none(cls, _) -> int | None: + """Don't accept a `count` value for the external metric!""" + return None