mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-22 07:33:00 +00:00
minor last fix-ups
This commit is contained in:
parent
4f67c6158d
commit
4205b04b05
2 changed files with 12 additions and 4 deletions
|
@ -44,15 +44,17 @@ def run_metrics(
|
||||||
async def async_main_loop() -> None:
|
async def async_main_loop() -> None:
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
|
|
||||||
while True:
|
|
||||||
with concurrent.futures.ThreadPoolExecutor(
|
with concurrent.futures.ThreadPoolExecutor(
|
||||||
max_workers=SETTINGS.threads,
|
max_workers=SETTINGS.threads,
|
||||||
) as pool:
|
) as pool:
|
||||||
|
while True:
|
||||||
|
# start interval and metrics at the same time
|
||||||
await asyncio.gather(
|
await asyncio.gather(
|
||||||
asyncio.sleep(SETTINGS.interval),
|
asyncio.sleep(SETTINGS.interval),
|
||||||
loop.run_in_executor(
|
loop.run_in_executor(
|
||||||
None, run_metrics,
|
None, run_metrics,
|
||||||
pool,
|
pool,
|
||||||
|
# metrics are reported in this order
|
||||||
metrics.cpu,
|
metrics.cpu,
|
||||||
metrics.memory,
|
metrics.memory,
|
||||||
metrics.disk,
|
metrics.disk,
|
||||||
|
|
|
@ -93,3 +93,9 @@ class ExternalMS(MetricSettings):
|
||||||
|
|
||||||
# wait at most this many seconds for each executable
|
# wait at most this many seconds for each executable
|
||||||
timeout: int = 60
|
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
|
||||||
|
|
Loading…
Reference in a new issue