Skip to content

Commit

Permalink
feat(metrics): a few changes
Browse files Browse the repository at this point in the history
- player_level is now apex_player_level
- added image metric
  • Loading branch information
chkpwd committed Feb 28, 2024
1 parent ead7c64 commit a54a670
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
self.current_map_name = ""
self.current_map_duration = 0
self.current_map_remaining = 0
self.current_map_image = ""

# Data from next map rotation
self.next_map_name = ""
Expand Down Expand Up @@ -69,6 +70,8 @@ def populate_data(self):
self.current_map_remaining = current_map_data["remainingMins"]
self.next_map_start = next_map_data["start"]

self.current_map_image = current_map_data["asset"]

class PlayerStatsCollector:
"""Class to collect player stats"""

Expand Down Expand Up @@ -287,6 +290,12 @@ def __init__(
registry=registry,
)

self.current_session_image = Info(
"apex_current_map_image",
"Image of the current map",
registry=registry,
)

self.next_session_map = Info(
"apex_next_map", "Name of the next map", registry=registry
)
Expand All @@ -312,7 +321,7 @@ def __init__(
"apex_player_platform", "Platform of the player", registry=registry
)

self.level = Gauge("player_level", "Level of the player", registry=registry)
self.level = Gauge("apex_player_level", "Level of the player", registry=registry)

self.next_level_percentage = Gauge(
"apex_player_next_level_percentage",
Expand Down Expand Up @@ -448,9 +457,8 @@ def collect(self):
# Define Prometheus Metrics for Map Stats
self.current_session_map.info({"map_name": current_map_name})
self.current_session_duration.set(self.map_stats_collector.current_map_duration)
self.current_session_remaining.set(
self.map_stats_collector.current_map_remaining
)
self.current_session_remaining.set(self.map_stats_collector.current_map_remaining)
self.current_session_image.info({"image": self.map_stats_collector.current_map_image})
self.next_session_map.info({"map_name": next_map_name})
self.next_session_duration.set(self.map_stats_collector.next_map_duration)
self.next_session_start.set(self.map_stats_collector.next_map_start - int(time.time()))
Expand Down

0 comments on commit a54a670

Please sign in to comment.