monitor req/s with kamon
This commit is contained in:
parent
c41d1d98f0
commit
83d3ee4e7c
|
@ -6,7 +6,7 @@ import play.api.mvc.Results._
|
|||
import play.api.{ Application, GlobalSettings, Mode }
|
||||
import kamon.Kamon
|
||||
|
||||
import lila.hub.actorApi.monitor.AddRequest
|
||||
import lila.api.KamonPusher.AddRequest
|
||||
|
||||
object Global extends GlobalSettings {
|
||||
|
||||
|
@ -25,7 +25,10 @@ object Global extends GlobalSettings {
|
|||
else if (Env.ai.ServerOnly) {
|
||||
Action(NotFound("I am an AI server")).some
|
||||
}
|
||||
else Env.i18n.requestHandler(req) orElse super.onRouteRequest(req)
|
||||
else {
|
||||
Env.api.kamonPusher ! AddRequest
|
||||
Env.i18n.requestHandler(req) orElse super.onRouteRequest(req)
|
||||
}
|
||||
|
||||
private def niceError(req: RequestHeader): Boolean =
|
||||
req.method == "GET" &&
|
||||
|
|
|
@ -118,7 +118,7 @@ final class Env(
|
|||
|
||||
lazy val cli = new Cli(system.lilaBus, renderer)
|
||||
|
||||
system.actorOf(Props(new KamonPusher))
|
||||
val kamonPusher = system.actorOf(Props(new KamonPusher))
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
|
|
@ -9,13 +9,13 @@ import lila.socket.actorApi.NbMembers
|
|||
|
||||
private final class KamonPusher extends Actor {
|
||||
|
||||
import KamonPusher._
|
||||
|
||||
override def preStart() {
|
||||
context.system.lilaBus.subscribe(self, 'nbMembers)
|
||||
context.system.scheduler.schedule(1 second, 1 second, self, Tick)
|
||||
}
|
||||
|
||||
private case object Tick
|
||||
|
||||
private val threadStats = ManagementFactory.getThreadMXBean
|
||||
private val app = lila.common.PlayApp
|
||||
|
||||
|
@ -24,9 +24,19 @@ private final class KamonPusher extends Actor {
|
|||
case NbMembers(nb) =>
|
||||
metrics.histogram("socket.member") record nb
|
||||
|
||||
case AddRequest =>
|
||||
metrics.counter("http.request").increment()
|
||||
|
||||
case Tick =>
|
||||
metrics.histogram("jvm.thread") record threadStats.getThreadCount
|
||||
metrics.histogram("jvm.daemon") record threadStats.getDaemonThreadCount
|
||||
metrics.histogram("jvm.uptime") record app.uptime.toStandardSeconds.getSeconds
|
||||
}
|
||||
}
|
||||
|
||||
object KamonPusher {
|
||||
|
||||
case object AddRequest
|
||||
|
||||
private case object Tick
|
||||
}
|
||||
|
|
|
@ -172,12 +172,6 @@ case class Analyse(
|
|||
case class AutoAnalyse(gameId: String)
|
||||
}
|
||||
|
||||
package monitor {
|
||||
case object AddRequest
|
||||
case object Update
|
||||
case class Move(millis: Option[Int])
|
||||
}
|
||||
|
||||
package round {
|
||||
case class MoveEvent(
|
||||
gameId: String,
|
||||
|
|
Loading…
Reference in a new issue