diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-08-04 22:07:38 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-08-04 22:07:38 -0300 |
commit | 9c0db0e0f85b17a7686429176f63ad92ab37f59a (patch) | |
tree | f573417057dd944dd5c66ff61d0a0cad5c22ee7c /kamon-statsd/src/main/scala/kamon | |
parent | 04a112ee8d49b23b8ebac7d28db805ee60c9d5d3 (diff) | |
download | Kamon-9c0db0e0f85b17a7686429176f63ad92ab37f59a.tar.gz Kamon-9c0db0e0f85b17a7686429176f63ad92ab37f59a.tar.bz2 Kamon-9c0db0e0f85b17a7686429176f63ad92ab37f59a.zip |
+ statsd: subscribe to user metrics
Diffstat (limited to 'kamon-statsd/src/main/scala/kamon')
-rw-r--r-- | kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala index e9350fae..ff273d9f 100644 --- a/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala +++ b/kamon-statsd/src/main/scala/kamon/statsd/StatsD.scala @@ -18,6 +18,7 @@ package kamon.statsd import akka.actor._ import kamon.Kamon +import kamon.metric.UserMetrics._ import kamon.metric._ import kamon.metrics._ import scala.concurrent.duration._ @@ -52,6 +53,12 @@ class StatsDExtension(system: ExtendedActorSystem) extends Kamon.Extension { val statsDMetricsListener = buildMetricsListener(tickInterval, flushInterval) + // Subscribe to all user metrics + Kamon(Metrics)(system).subscribe(UserHistograms, "*", statsDMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserCounters, "*", statsDMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserMinMaxCounters, "*", statsDMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserGauges, "*", statsDMetricsListener, permanently = true) + // Subscribe to Actors val includedActors = statsDConfig.getStringList("includes.actor").asScala for (actorPathPattern ← includedActors) { @@ -107,7 +114,16 @@ class SimpleMetricKeyGenerator(config: Config) extends StatsD.MetricKeyGenerator def generateKey(groupIdentity: MetricGroupIdentity, metricIdentity: MetricIdentity): String = { val normalizedGroupName = groupIdentity.name.replace(": ", "-").replace(" ", "_").replace("/", "_") - s"${application}.${normalizedLocalhostName}.${groupIdentity.category.name}.${normalizedGroupName}.${metricIdentity.name}" + + if (isUserMetric(groupIdentity)) + s"${application}.${normalizedLocalhostName}.${groupIdentity.category.name}.${normalizedGroupName}" + else + s"${application}.${normalizedLocalhostName}.${groupIdentity.category.name}.${normalizedGroupName}.${metricIdentity.name}" + } + + def isUserMetric(groupIdentity: MetricGroupIdentity): Boolean = groupIdentity match { + case someUserMetric: UserMetricGroup ⇒ true + case everythingElse ⇒ false } } |