diff options
author | Joffrey Bion <joffrey.bion@gmail.com> | 2021-03-14 01:14:20 +0100 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@gmail.com> | 2021-03-14 01:14:31 +0100 |
commit | 486f1a3e6e268cf7669dd8f9e2d37b9e91c3147f (patch) | |
tree | 0826df0a937d8852e24287bb5c5e9106a0272971 /sw-server | |
parent | Better metrics for connected players (diff) | |
download | seven-wonders-486f1a3e6e268cf7669dd8f9e2d37b9e91c3147f.tar.gz seven-wonders-486f1a3e6e268cf7669dd8f9e2d37b9e91c3147f.tar.bz2 seven-wonders-486f1a3e6e268cf7669dd8f9e2d37b9e91c3147f.zip |
Move bot timeout metric before disconnect() call (in case of failure)
Diffstat (limited to 'sw-server')
-rw-r--r-- | sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt | 2 | ||||
-rw-r--r-- | sw-server/src/main/kotlin/org/luxons/sevenwonders/server/metrics/MetricsUtils.kt | 4 |
2 files changed, 3 insertions, 3 deletions
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<Tag> { 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()), ) } |