From 5c4241c089fa402e9cc1fbbc568989ea139bc1fa Mon Sep 17 00:00:00 2001 From: Kunjan Date: Tue, 29 Oct 2024 12:52:19 -0700 Subject: [PATCH] [MISC] Set label value to timestamp over 0, to keep track of recent history (#9777) Signed-off-by: Kunjan Patel Signed-off-by: Randall Smith --- vllm/engine/metrics.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vllm/engine/metrics.py b/vllm/engine/metrics.py index 0f5615ff14db1..9ed30e1e99857 100644 --- a/vllm/engine/metrics.py +++ b/vllm/engine/metrics.py @@ -1,3 +1,4 @@ +import time from typing import TYPE_CHECKING from typing import Counter as CollectionsCounter from typing import Dict, List, Optional, Type, Union, cast @@ -253,6 +254,10 @@ def labels(self, **labels): def set(self, value: Union[int, float]): return self._gauge.set(value) + def set_to_current_time(self): + # ray metrics doesn't have set_to_current time, https://docs.ray.io/en/latest/_modules/ray/util/metrics.html + return self._gauge.set(time.time()) + class _RayCounterWrapper: """Wraps around ray.util.metrics.Counter to provide same API as @@ -479,7 +484,7 @@ def _log_histogram(self, histogram, data: Union[List[int], histogram.labels(**self.labels).observe(datum) def _log_gauge_string(self, gauge, data: Dict[str, str]) -> None: - gauge.labels(**data).set(1) + gauge.labels(**data).set_to_current_time() def _log_prometheus(self, stats: Stats) -> None: # System state data