Skip to content

Commit 0ad216f

Browse files
authored
[MISC] Set label value to timestamp over 0, to keep track of recent history (vllm-project#9777)
Signed-off-by: Kunjan Patel <[email protected]>
1 parent 7585ec9 commit 0ad216f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

vllm/engine/metrics.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
from typing import TYPE_CHECKING
23
from typing import Counter as CollectionsCounter
34
from typing import Dict, List, Optional, Type, Union, cast
@@ -253,6 +254,10 @@ def labels(self, **labels):
253254
def set(self, value: Union[int, float]):
254255
return self._gauge.set(value)
255256

257+
def set_to_current_time(self):
258+
# ray metrics doesn't have set_to_current time, https://docs.ray.io/en/latest/_modules/ray/util/metrics.html
259+
return self._gauge.set(time.time())
260+
256261

257262
class _RayCounterWrapper:
258263
"""Wraps around ray.util.metrics.Counter to provide same API as
@@ -479,7 +484,7 @@ def _log_histogram(self, histogram, data: Union[List[int],
479484
histogram.labels(**self.labels).observe(datum)
480485

481486
def _log_gauge_string(self, gauge, data: Dict[str, str]) -> None:
482-
gauge.labels(**data).set(1)
487+
gauge.labels(**data).set_to_current_time()
483488

484489
def _log_prometheus(self, stats: Stats) -> None:
485490
# System state data

0 commit comments

Comments
 (0)