From 8d3200d5f125f508403eb9b6fe4fafb11c9c3e9f Mon Sep 17 00:00:00 2001 From: benjamin-lawson Date: Wed, 6 Mar 2024 15:24:41 -0500 Subject: [PATCH] Add new dimension to matchmaking search duration in prometheus --- server/matchmaker/matchmaker_queue.py | 9 +++++---- server/metrics.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/matchmaker/matchmaker_queue.py b/server/matchmaker/matchmaker_queue.py index 778407981..b43e5e9a6 100644 --- a/server/matchmaker/matchmaker_queue.py +++ b/server/matchmaker/matchmaker_queue.py @@ -19,8 +19,9 @@ class MatchmakerSearchTimer: - def __init__(self, queue_name): - self.queue_name = queue_name + def __init__(self, queue_name: str, players_in_queue: int): + self.queue_name = queue_name, + self.players_in_queue = players_in_queue def __enter__(self): self.start_time = time.monotonic() @@ -34,7 +35,7 @@ def __exit__(self, exc_type, exc_value, traceback): else: status = "errored" - metric = metrics.matchmaker_search_duration.labels(self.queue_name, status) + metric = metrics.matchmaker_search_duration.labels(self.queue_name, status, self.players_in_queue) metric.observe(total_time) @@ -140,7 +141,7 @@ async def search(self, search: Search) -> None: assert search is not None try: - with MatchmakerSearchTimer(self.name): + with MatchmakerSearchTimer(self.name, self.num_players): self.push(search) await search.await_match() self._logger.debug("Search complete: %s", search) diff --git a/server/metrics.py b/server/metrics.py index 52b725c1f..6f7b67a4e 100644 --- a/server/metrics.py +++ b/server/metrics.py @@ -59,7 +59,7 @@ class MatchLaunch: matchmaker_search_duration = Histogram( "server_matchmaker_queue_search_duration_seconds", "Time spent searching for matches per search in seconds", - ["queue", "status"], + ["queue", "status", "players_in_queue"], buckets=[30, 60, 120, 180, 240, 300, 420, 600, 900, 1800, 3600], )