diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-26 20:00:08 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-26 20:00:08 +0100 |
commit | bb9189e19c622efa0dfb4552d272ef1bcabca47b (patch) | |
tree | 27fb50b2d42770996157f6d340e463f31f9bbf21 | |
parent | 4a6b666fc45d3f25cfaad3bcf90e611329c5c49a (diff) | |
download | Kamon-bb9189e19c622efa0dfb4552d272ef1bcabca47b.tar.gz Kamon-bb9189e19c622efa0dfb4552d272ef1bcabca47b.tar.bz2 Kamon-bb9189e19c622efa0dfb4552d272ef1bcabca47b.zip |
= statsd: pick the tick duration from the metrics extension settings.
-rw-r--r-- | kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala index e5a15a9d..d363bdd4 100644 --- a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala +++ b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala @@ -40,10 +40,11 @@ class StatsDExtension(system: ExtendedActorSystem) extends Kamon.Extension { private val config = system.settings.config private val statsDConfig = config.getConfig("kamon.statsd") + val metricsExtension = Kamon(Metrics) - val tickInterval = config.getDuration("kamon.metrics.tick-interval", MILLISECONDS) + val tickInterval = metricsExtension.settings.tickInterval val statsDHost = new InetSocketAddress(statsDConfig.getString("hostname"), statsDConfig.getInt("port")) - val flushInterval = statsDConfig.getDuration("flush-interval", MILLISECONDS) + val flushInterval = statsDConfig.getFiniteDuration("flush-interval") val maxPacketSizeInBytes = statsDConfig.getBytes("max-packet-size") val keyGeneratorFQCN = statsDConfig.getString("metric-key-generator") @@ -52,11 +53,11 @@ class StatsDExtension(system: ExtendedActorSystem) extends Kamon.Extension { val subscriptions = statsDConfig.getConfig("subscriptions") subscriptions.firstLevelKeys.map { subscriptionCategory ⇒ subscriptions.getStringList(subscriptionCategory).asScala.foreach { pattern ⇒ - Kamon(Metrics).subscribe(subscriptionCategory, pattern, statsDMetricsListener, permanently = true) + metricsExtension.subscribe(subscriptionCategory, pattern, statsDMetricsListener, permanently = true) } } - def buildMetricsListener(tickInterval: Long, flushInterval: Long, keyGeneratorFQCN: String, config: Config): ActorRef = { + def buildMetricsListener(tickInterval: FiniteDuration, flushInterval: FiniteDuration, keyGeneratorFQCN: String, config: Config): ActorRef = { assert(flushInterval >= tickInterval, "StatsD flush-interval needs to be equal or greater to the tick-interval") val keyGenerator = system.dynamicAccess.createInstanceFor[MetricKeyGenerator](keyGeneratorFQCN, (classOf[Config], config) :: Nil).get @@ -69,7 +70,7 @@ class StatsDExtension(system: ExtendedActorSystem) extends Kamon.Extension { // No need to buffer the metrics, let's go straight to the metrics sender. metricsSender } else { - system.actorOf(TickMetricSnapshotBuffer.props(flushInterval.toInt.millis, metricsSender), "statsd-metrics-buffer") + system.actorOf(TickMetricSnapshotBuffer.props(flushInterval, metricsSender), "statsd-metrics-buffer") } } }
\ No newline at end of file |