Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #930 - Add new dimension to matchmaking search duration in prometheus #1010

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions server/matchmaker/matchmaker_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered changing the constructor to store a reference to the queue itself rather than store the number of players when the search starts, but I didn't want to hold open any potential connections.

self.queue_name = queue_name,
self.players_in_queue = players_in_queue

def __enter__(self):
self.start_time = time.monotonic()
Expand All @@ -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)


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion server/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)

Expand Down
Loading