diff options
Diffstat (limited to 'kamon-datadog/src/main/scala/kamon')
-rw-r--r-- | kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala | 7 | ||||
-rw-r--r-- | kamon-datadog/src/main/scala/kamon/datadog/DatadogMetricsSender.scala | 19 |
2 files changed, 22 insertions, 4 deletions
diff --git a/kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala b/kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala index 63557781..0f105721 100644 --- a/kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala +++ b/kamon-datadog/src/main/scala/kamon/datadog/Datadog.scala @@ -18,6 +18,7 @@ package kamon.datadog import akka.actor._ import kamon.Kamon +import kamon.metric.UserMetrics.{ UserGauges, UserMinMaxCounters, UserCounters, UserHistograms } import kamon.metric._ import kamon.metrics._ import kamon.metrics.CPUMetrics @@ -48,6 +49,12 @@ class DatadogExtension(system: ExtendedActorSystem) extends Kamon.Extension { val datadogMetricsListener = buildMetricsListener(tickInterval, flushInterval) + // Subscribe to all user metrics + Kamon(Metrics)(system).subscribe(UserHistograms, "*", datadogMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserCounters, "*", datadogMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserMinMaxCounters, "*", datadogMetricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserGauges, "*", datadogMetricsListener, permanently = true) + // Subscribe to Actors val includedActors = datadogConfig.getStringList("includes.actor").asScala for (actorPathPattern ← includedActors) { diff --git a/kamon-datadog/src/main/scala/kamon/datadog/DatadogMetricsSender.scala b/kamon-datadog/src/main/scala/kamon/datadog/DatadogMetricsSender.scala index 0f67cc34..5ab0589c 100644 --- a/kamon-datadog/src/main/scala/kamon/datadog/DatadogMetricsSender.scala +++ b/kamon-datadog/src/main/scala/kamon/datadog/DatadogMetricsSender.scala @@ -22,6 +22,7 @@ import java.net.InetSocketAddress import akka.util.ByteString import kamon.metric.Subscriptions.TickMetricSnapshot import java.text.{ DecimalFormatSymbols, DecimalFormat } +import kamon.metric.UserMetrics.UserMetricGroup import kamon.metric.instrument.{ Counter, Histogram } import kamon.metric.{ MetricIdentity, MetricGroupIdentity } import java.util.Locale @@ -88,12 +89,22 @@ class DatadogMetricsSender(remote: InetSocketAddress, maxPacketSizeInBytes: Long def encodeStatsDCounter(count: Long): String = count.toString + "|c" def buildMetricName(groupIdentity: MetricGroupIdentity, metricIdentity: MetricIdentity): String = - s"$appName.${groupIdentity.category.name}.${metricIdentity.name}" + if (isUserMetric(groupIdentity)) + s"$appName.${groupIdentity.category.name}.${groupIdentity.name}" + else + s"$appName.${groupIdentity.category.name}.${metricIdentity.name}" def buildIdentificationTag(groupIdentity: MetricGroupIdentity, metricIdentity: MetricIdentity): String = { - // Make the automatic HTTP trace names a bit more friendly - val normalizedEntityName = groupIdentity.name.replace(": ", ":") - s"|#${groupIdentity.category.name}:${normalizedEntityName}" + if (isUserMetric(groupIdentity)) "" else { + // Make the automatic HTTP trace names a bit more friendly + val normalizedEntityName = groupIdentity.name.replace(": ", ":") + s"|#${groupIdentity.category.name}:${normalizedEntityName}" + } + } + + def isUserMetric(groupIdentity: MetricGroupIdentity): Boolean = groupIdentity match { + case someUserMetric: UserMetricGroup ⇒ true + case everythingElse ⇒ false } } |