aboutsummaryrefslogtreecommitdiff
path: root/src
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 /src
parentc62054d92704d292c3533613f66bac4dc9c7216a (diff)
downloaddriver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.tar.gz
driver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.tar.bz2
driver-core-0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a.zip
Implement metrics collection with Kamon (#186)
Diffstat (limited to 'src')
-rw-r--r--src/main/resources/reference.conf20
-rw-r--r--src/main/scala/xyz/driver/core/app/DriverApp.scala7
2 files changed, 27 insertions, 0 deletions
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)