From 486f1a3e6e268cf7669dd8f9e2d37b9e91c3147f Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 14 Mar 2021 01:14:20 +0100 Subject: Move bot timeout metric before disconnect() call (in case of failure) --- .../org/luxons/sevenwonders/server/controllers/LobbyController.kt | 2 +- .../kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sw-server/src') diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt index 56e94493..9fb1603a 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt @@ -164,10 +164,10 @@ class LobbyController( bot.joinAndAutoPlay(lobby.id) } if (result == null) { + meterRegistry.counter("bot.timeout", lobby.playerCountsTags()).increment() val timeoutDuration = action.globalBotTimeoutMillis.milliseconds logger.error("Bot {} timed out after {}", action.botDisplayName, timeoutDuration) bot.disconnect() - meterRegistry.counter("bot.timeout", lobby.playerCountsTags()).increment() } } } diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt index 6b91428e..8d6570a2 100644 --- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt +++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt @@ -7,7 +7,7 @@ fun Lobby.playerCountsTags(): List { val players = getPlayers() return listOf( Tag.of("nPlayers", players.size.toString()), - Tag.of("nHumans", players.filter { it.isHuman }.size.toString()), - Tag.of("nBots", players.filterNot { it.isHuman }.size.toString()), + Tag.of("nHumans", players.count { it.isHuman }.toString()), + Tag.of("nBots", players.count { !it.isHuman }.toString()), ) } -- cgit