configure kamon for play and akka, with statsd backend

kamon
Thibault Duplessis 2016-03-07 19:01:39 +07:00
parent 8f30a7206c
commit 02c75dd13e
5 changed files with 112 additions and 30 deletions

View File

@ -12,6 +12,7 @@ net {
version = 876
}
}
forcedev = false
play {
server {
netty {
@ -670,4 +671,64 @@ akka {
log-config-on-start = off
log-dead-letters-during-shutdown = off
}
forcedev = false
kamon {
metric {
tick-interval = 1 second
filters {
akka-actor {
includes = [ ${lobby.socket.name} ]
# excludes = [ "my-app/system/**", "my-app/user/worker-helper" ]
}
# akka-dispatcher {
# includes = [ "my-app/akka.actor.default-dispatcher", "my-app/database-dispatcher" ]
# }
# akka-router {
# includes = [ "my-app/user/some-router" ]
# }
}
}
statsd {
# Hostname and port in which your StatsD is running. Remember that StatsD packets are sent using UDP and
# setting unreachable hosts and/or not open ports wont be warned by the Kamon, your data wont go anywhere.
hostname = "127.0.0.1"
port = 8125
# Interval between metrics data flushes to StatsD. It's value must be equal or greater than the
# kamon.metrics.tick-interval setting.
flush-interval = 1 second
# Max packet size for UDP metrics data sent to StatsD.
max-packet-size = 1024 bytes
# Subscription patterns used to select which metrics will be pushed to StatsD. Note that first, metrics
# collection for your desired entities must be activated under the kamon.metrics.filters settings.
includes {
actor = [ "*" ]
trace = [ "*" ]
dispatcher = [ "*" ]
}
simple-metric-key-generator {
# Application prefix for all metrics pushed to StatsD. The default namespacing scheme for metrics follows
# this pattern:
# application.host.entity.entity-name.metric-name
application = "activator-akka-kamon-statsd"
}
}
play {
include-trace-token-header = true
trace-token-header-name = "X-Trace-Token"
}
modules {
kamon-statsd.auto-start = no
kamon-log-reporter.auto-start = yes
kamon-system-metrics.auto-start = no
}
}

View File

@ -10,24 +10,29 @@ object ApplicationBuild extends Build {
import BuildSettings._
import Dependencies._
lazy val root = Project("lila", file(".")) enablePlugins _root_.play.sbt.PlayScala settings (
scalaVersion := globalScalaVersion,
resolvers ++= Dependencies.Resolvers.commons,
scalacOptions := compilerOptions,
incOptions := incOptions.value.withNameHashing(true),
updateOptions := updateOptions.value.withCachedResolution(true),
sources in doc in Compile := List(),
// disable publishing the main API jar
publishArtifact in (Compile, packageDoc) := false,
// disable publishing the main sources jar
publishArtifact in (Compile, packageSrc) := false,
// don't stage the conf dir
externalizeResources := false,
// offline := true,
libraryDependencies ++= Seq(
scalaz, scalalib, hasher, config, apache,
jgit, findbugs, RM, PRM, akka.actor, akka.slf4j,
spray.caching, maxmind, prismic),
lazy val root = Project("lila", file("."))
.enablePlugins(_root_.play.sbt.PlayScala)
.dependsOn(api)
.aggregate(api)
.settings(Seq(
scalaVersion := globalScalaVersion,
resolvers ++= Dependencies.Resolvers.commons,
scalacOptions := compilerOptions,
incOptions := incOptions.value.withNameHashing(true),
updateOptions := updateOptions.value.withCachedResolution(true),
sources in doc in Compile := List(),
// disable publishing the main API jar
publishArtifact in (Compile, packageDoc) := false,
// disable publishing the main sources jar
publishArtifact in (Compile, packageSrc) := false,
// don't stage the conf dir
externalizeResources := false,
// offline := true,
libraryDependencies ++= Seq(
scalaz, scalalib, hasher, config, apache,
jgit, findbugs, RM, PRM, akka.actor, akka.slf4j,
spray.caching, maxmind, prismic,
kamon.core, kamon.play, kamon.akka),
TwirlKeys.templateImports ++= Seq(
"lila.game.{ Game, Player, Pov }",
"lila.tournament.Tournament",
@ -36,12 +41,21 @@ object ApplicationBuild extends Build {
"lila.app.templating.Environment._",
"lila.api.Context",
"lila.common.paginator.Paginator"),
watchSources <<= sourceDirectory in Compile map { sources =>
(sources ** "*").get
},
// trump sbt-web into not looking at public/
resourceDirectory in Assets := (sourceDirectory in Compile).value / "assets"
) dependsOn api aggregate api
watchSources <<= sourceDirectory in Compile map { sources =>
(sources ** "*").get
},
// trump sbt-web into not looking at public/
resourceDirectory in Assets := (sourceDirectory in Compile).value / "assets"
))
// ) ++ aspectjSettings ++ Seq(
// // Here we are effectively adding the `-javaagent` JVM startup
// // option with the location of the AspectJ Weaver provided by
// // the sbt-aspectj plugin.
// javaOptions in run <++= AspectjKeys.weaverOptions in Aspectj,
// // We need to ensure that the JVM is forked for the
// // AspectJ Weaver to kick in properly and do it's magic.
// fork in run := true
// ))
lazy val modules = Seq(
chess, common, db, rating, user, security, wiki, hub, socket,

View File

@ -19,7 +19,8 @@ object BuildSettings {
// disable publishing the main API jar
publishArtifact in (Compile, packageDoc) := false,
// disable publishing the main sources jar
publishArtifact in (Compile, packageSrc) := false)
publishArtifact in (Compile, packageSrc) := false
)
def defaultDeps = Seq(scalaz, scalalib, jodaTime, spray.util, ws)

View File

@ -31,8 +31,8 @@ object Dependencies {
val hasher = "com.roundeights" %% "hasher" % "1.2.0"
val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % "3.2.0.201312181205-r"
val jodaTime = "joda-time" % "joda-time" % "2.9.1"
val RM = "org.reactivemongo" %% "reactivemongo" % "0.11.9-SNAPSHOT"
val PRM = ("org.reactivemongo" %% "play2-reactivemongo" % "0.11.9-SNAPSHOT").exclude("org.reactivemongo", "reactivemongo")
val RM = "org.reactivemongo" %% "reactivemongo" % "0.11.9"
val PRM = "org.reactivemongo" %% "play2-reactivemongo" % "0.11.9"
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.2.3-THIB"
val prismic = "io.prismic" %% "scala-kit" % "1.2.11-THIB"
@ -51,4 +51,10 @@ object Dependencies {
val actor = "com.typesafe.akka" %% "akka-actor" % version
val slf4j = "com.typesafe.akka" %% "akka-slf4j" % version
}
object kamon {
val version = "0.5.2"
val core = "io.kamon" %% "kamon-core" % version
val play = "io.kamon" %% "kamon-play-24" % version
val akka = "io.kamon" %% "kamon-akka" % version
}
}

View File

@ -1,6 +1,6 @@
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")
// addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.6")
// addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.10.4")
addSbtPlugin("io.kamon" % "aspectj-play-runner" % "0.1.3")