From 0d4576ad9d184cfdffc6f2ea35983c05ebac3f2a Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Fri, 27 Jul 2018 10:23:24 -0600 Subject: Implement metrics collection with Kamon (#186) --- src/main/resources/reference.conf | 20 ++++++++++++++++++++ src/main/scala/xyz/driver/core/app/DriverApp.scala | 7 +++++++ 2 files changed, 27 insertions(+) (limited to 'src/main') 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) -- cgit v1.2.3