Skip to content

Commit

Permalink
[MISC] Set label value to timestamp over 0, to keep track of recent h…
Browse files Browse the repository at this point in the history
…istory (vllm-project#9777)

Signed-off-by: Kunjan Patel <[email protected]>
  • Loading branch information
coolkp authored Oct 29, 2024
1 parent 7585ec9 commit 0ad216f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vllm/engine/metrics.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ad216f

Please sign in to comment.