diff --git a/modules/coordinator/src/main/scala/de/nowchess/coordinator/service/CacheEvictionManager.scala b/modules/coordinator/src/main/scala/de/nowchess/coordinator/service/CacheEvictionManager.scala index 1263772..ab48e1e 100644 --- a/modules/coordinator/src/main/scala/de/nowchess/coordinator/service/CacheEvictionManager.scala +++ b/modules/coordinator/src/main/scala/de/nowchess/coordinator/service/CacheEvictionManager.scala @@ -42,9 +42,7 @@ class CacheEvictionManager: redisPrefix = prefix def evictStaleGames: Unit = - meterRegistry.timer("nowchess.coordinator.cache.eviction.duration").record { () => - runEviction() - } + meterRegistry.timer("nowchess.coordinator.cache.eviction.duration").record((() => runEviction()): Runnable) private def runEviction(): Unit = log.info("Starting cache eviction scan") diff --git a/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala b/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala index 678c484..9becc0a 100644 --- a/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala +++ b/modules/core/src/main/scala/de/nowchess/chess/engine/GameEngine.scala @@ -369,7 +369,7 @@ class GameEngine( case GameResult.Draw(_) => "draw.insufficient" case _ => "timeout" Option(gamesCompletedCounter(tag)).foreach(_.increment()) - activeGamesCount.decrementAndGet() + GameEngine.activeGamesCount.decrementAndGet() notifyObservers(TimeFlagEvent(currentContext, flagged)) private def scheduleExpiryCheck(cs: ClockState): Unit = @@ -406,7 +406,7 @@ class GameEngine( private def executeMove(move: Move): Unit = Option(movesDurationTimer) match - case Some(timer) => timer.record(() => executeMoveBody(move)) + case Some(timer) => timer.record((() => executeMoveBody(move)): Runnable) case None => executeMoveBody(move) Option(movesProcessedCounter).foreach(_.increment()) diff --git a/modules/official-bots/src/main/scala/de/nowchess/bot/service/OfficialBotService.scala b/modules/official-bots/src/main/scala/de/nowchess/bot/service/OfficialBotService.scala index 9cfd11c..82ad456 100644 --- a/modules/official-bots/src/main/scala/de/nowchess/bot/service/OfficialBotService.scala +++ b/modules/official-bots/src/main/scala/de/nowchess/bot/service/OfficialBotService.scala @@ -88,8 +88,8 @@ class OfficialBotService: botController.getBot(botName).orElse(botController.getBot(level.toString.toLowerCase)).foreach { bot => FenParser.parseFen(fen).toOption.foreach { context => val timer = meterRegistry.timer("nowchess.bot.move.duration", "bot", botName) - val moveOpt = timer.recordCallable(() => bot(context)) - moveOpt.flatten.foreach { move => + val moveOpt = timer.recordCallable[Option[Move]](() => bot(context)) + moveOpt.foreach { move => meterRegistry.counter("nowchess.bot.moves.computed", "bot", botName).increment() val uci = toUci(move) val c2sTopic = s"${redisConfig.prefix}:game:$gameId:c2s" diff --git a/modules/store/src/main/scala/de/nowchess/store/service/GameWritebackService.scala b/modules/store/src/main/scala/de/nowchess/store/service/GameWritebackService.scala index ce0ab9b..0444d7b 100644 --- a/modules/store/src/main/scala/de/nowchess/store/service/GameWritebackService.scala +++ b/modules/store/src/main/scala/de/nowchess/store/service/GameWritebackService.scala @@ -33,7 +33,7 @@ class GameWritebackService: @Transactional def writeBack(event: GameWritebackEventDto): Unit = - writebackTimer.record(() => doWriteBack(event)) + writebackTimer.record((() => doWriteBack(event)): Runnable) private def doWriteBack(event: GameWritebackEventDto): Unit = repository.findByGameId(event.gameId) match