don't log move_direction_counts into metric because looking almost the same
This commit is contained in:
@@ -26,13 +26,13 @@ class ServerMetricsCollector:
|
|||||||
# 'move': 0,
|
# 'move': 0,
|
||||||
# 'end': 0,
|
# 'end': 0,
|
||||||
# },
|
# },
|
||||||
'move_direction_counts': {
|
# 'move_direction_counts': {
|
||||||
'up': 0,
|
# 'up': 0,
|
||||||
'down': 0,
|
# 'down': 0,
|
||||||
'left': 0,
|
# 'left': 0,
|
||||||
'right': 0,
|
# 'right': 0,
|
||||||
'unknown': 0,
|
# 'unknown': 0,
|
||||||
},
|
# },
|
||||||
'move_response_time_ms_total': 0.0,
|
'move_response_time_ms_total': 0.0,
|
||||||
'move_response_time_ms_max': 0.0,
|
'move_response_time_ms_max': 0.0,
|
||||||
'last_game_start_unix': 0,
|
'last_game_start_unix': 0,
|
||||||
@@ -76,12 +76,12 @@ class ServerMetricsCollector:
|
|||||||
self._metrics['move_response_time_ms_max'],
|
self._metrics['move_response_time_ms_max'],
|
||||||
elapsed_ms,
|
elapsed_ms,
|
||||||
)
|
)
|
||||||
move_counts = self._metrics['move_direction_counts']
|
# move_counts = self._metrics['move_direction_counts']
|
||||||
if direction in move_counts:
|
# if direction in move_counts:
|
||||||
move_counts[direction] += 1
|
# move_counts[direction] += 1
|
||||||
else:
|
# else:
|
||||||
move_counts['unknown'] += 1
|
# move_counts['unknown'] += 1
|
||||||
self._metrics['last_move_unix'] = int(time.time())
|
# self._metrics['last_move_unix'] = int(time.time())
|
||||||
await self._auto_publish()
|
await self._auto_publish()
|
||||||
|
|
||||||
async def record_game_end(self, game_state:dict) -> None:
|
async def record_game_end(self, game_state:dict) -> None:
|
||||||
@@ -156,8 +156,8 @@ class ServerMetricsCollector:
|
|||||||
'avg_turns_per_game': round(avg_turns, 2),
|
'avg_turns_per_game': round(avg_turns, 2),
|
||||||
'win_rate': round(win_rate, 4),
|
'win_rate': round(win_rate, 4),
|
||||||
'avg_move_response_ms': round(avg_move_ms, 2),
|
'avg_move_response_ms': round(avg_move_ms, 2),
|
||||||
'http_requests_by_endpoint': dict(self._metrics['http_requests_by_endpoint']),
|
# 'http_requests_by_endpoint': dict(self._metrics['http_requests_by_endpoint']),
|
||||||
'move_direction_counts': dict(self._metrics['move_direction_counts']),
|
# 'move_direction_counts': dict(self._metrics['move_direction_counts']),
|
||||||
'oldest_active_game_age_sec': oldest_active_age,
|
'oldest_active_game_age_sec': oldest_active_age,
|
||||||
'stale_game_timeout_sec': self._stale_game_timeout_sec,
|
'stale_game_timeout_sec': self._stale_game_timeout_sec,
|
||||||
'active_games_stale': report_stale_candidates,
|
'active_games_stale': report_stale_candidates,
|
||||||
@@ -243,19 +243,19 @@ class ServerMetricsCollector:
|
|||||||
f'snake_active_games_stale {snapshot["active_games_stale"]}',
|
f'snake_active_games_stale {snapshot["active_games_stale"]}',
|
||||||
]
|
]
|
||||||
|
|
||||||
lines.extend([
|
# lines.extend([
|
||||||
'# HELP snake_http_requests_by_endpoint_total Requests served grouped by endpoint.',
|
# '# HELP snake_http_requests_by_endpoint_total Requests served grouped by endpoint.',
|
||||||
'# TYPE snake_http_requests_by_endpoint_total counter',
|
# '# TYPE snake_http_requests_by_endpoint_total counter',
|
||||||
])
|
# ])
|
||||||
for endpoint, count in snapshot['http_requests_by_endpoint'].items():
|
# for endpoint, count in snapshot['http_requests_by_endpoint'].items():
|
||||||
lines.append(f'snake_http_requests_by_endpoint_total{{endpoint="{endpoint}"}} {count}')
|
# lines.append(f'snake_http_requests_by_endpoint_total{{endpoint="{endpoint}"}} {count}')
|
||||||
|
|
||||||
lines.extend([
|
# lines.extend([
|
||||||
'# HELP snake_moves_by_direction_total Move responses grouped by direction.',
|
# '# HELP snake_moves_by_direction_total Move responses grouped by direction.',
|
||||||
'# TYPE snake_moves_by_direction_total counter',
|
# '# TYPE snake_moves_by_direction_total counter',
|
||||||
])
|
# ])
|
||||||
for direction, count in snapshot['move_direction_counts'].items():
|
# for direction, count in snapshot['move_direction_counts'].items():
|
||||||
lines.append(f'snake_moves_by_direction_total{{direction="{direction}"}} {count}')
|
# lines.append(f'snake_moves_by_direction_total{{direction="{direction}"}} {count}')
|
||||||
|
|
||||||
return '\n'.join(lines) + '\n'
|
return '\n'.join(lines) + '\n'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user