aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2018-07-27 10:23:24 -0600
committerGitHub <noreply@github.com>2018-07-27 10:23:24 -0600
commit0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a (patch)
tree69adda7d202328eaa81e642fee3ca48a2960462f
parentc62054d92704d292c3533613f66bac4dc9c7216a (diff)
downloaddriver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.tar.gz
driver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.tar.bz2
driver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.zip
Implement metrics collection with Kamon (#186)
-rw-r--r--build.sbt4
-rw-r--r--src/main/resources/reference.conf20
-rw-r--r--src/main/scala/xyz/driver/core/app/DriverApp.scala7
3 files changed, 31 insertions, 0 deletions
diff --git a/build.sbt b/build.sbt
index fe88929..4dbb827 100644
--- a/build.sbt
+++ b/build.sbt
@@ -14,6 +14,10 @@ lazy val core = (project in file("."))
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpV,
"com.typesafe.akka" %% "akka-http-testkit" % akkaHttpV,
"com.pauldijou" %% "jwt-core" % "0.16.0",
+ "io.kamon" %% "kamon-core" % "1.1.3",
+ "io.kamon" %% "kamon-statsd" % "1.0.0",
+ "io.kamon" %% "kamon-system-metrics" % "1.0.0",
+ "io.kamon" %% "kamon-akka-2.5" % "1.0.0",
"org.scalatest" %% "scalatest" % "3.0.5" % "test",
"org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
"org.scalaz" %% "scalaz-core" % "7.2.24",
diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf
index fd2da69..ac4b253 100644
--- a/src/main/resources/reference.conf
+++ b/src/main/resources/reference.conf
@@ -69,3 +69,23 @@ swagger {
licenseUrl = "http://www.apache.org/licenses/LICENSE-2.0"
}
}
+
+# Kamon provides monitoring capabilities
+kamon {
+ system-metrics {
+ # sigar reports host-specific metrics. Kubernetes takes care of
+ # that for Driver services.
+ host.enabled = false
+
+ # JVM-related metrics
+ jmx.enabled = true
+ }
+
+ statsd {
+ hostname = localhost
+ port = 8125
+ simple-metric-key-generator {
+ include-hostname = false
+ }
+ }
+}
diff --git a/src/main/scala/xyz/driver/core/app/DriverApp.scala b/src/main/scala/xyz/driver/core/app/DriverApp.scala
index 6dd98e3..9cb53af 100644
--- a/src/main/scala/xyz/driver/core/app/DriverApp.scala
+++ b/src/main/scala/xyz/driver/core/app/DriverApp.scala
@@ -12,6 +12,9 @@ import akka.stream.ActorMaterializer
import com.typesafe.config.Config
import com.typesafe.scalalogging.Logger
import io.swagger.models.Scheme
+import kamon.Kamon
+import kamon.statsd.StatsDReporter
+import kamon.system.SystemMetrics
import org.slf4j.{LoggerFactory, MDC}
import xyz.driver.core
import xyz.driver.core.rest._
@@ -47,6 +50,10 @@ class DriverApp(
val appEnvironment: String = config.getString("application.environment")
def run(): Unit = {
+ Console.print("Starting metrics collection...\n")
+ Kamon.addReporter(new StatsDReporter())
+ SystemMetrics.startCollecting()
+ Console.print("Metrics collection started\n")
activateServices(modules)
scheduleServicesDeactivation(modules)
bindHttp(modules)