diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-03-05 23:39:44 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-03-09 23:09:08 +0100 |
commit | 959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b (patch) | |
tree | 27c1fe8f22429fe3820f988ab17caaf8e4a6fa3a /kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala | |
parent | 69ea63923e0d3697f8ca4c7eb9cb808821832aa2 (diff) | |
download | Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.gz Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.tar.bz2 Kamon-959ce3573253ec4ac5b837d8a9c9e70f1f80bd6b.zip |
! all: introduced support for metric tags.
Diffstat (limited to 'kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala')
-rw-r--r-- | kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala index 41ed9661..6919a967 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/CustomMetricExtractor.scala @@ -16,17 +16,22 @@ package kamon.newrelic -import kamon.metric.{ SimpleMetricsImpl, EntitySnapshot, Entity } +import kamon.metric.{ EntitySnapshot, Entity } import kamon.metric.instrument.CollectionContext object CustomMetricExtractor extends MetricExtractor { def extract(settings: AgentSettings, collectionContext: CollectionContext, metrics: Map[Entity, EntitySnapshot]): Map[MetricID, MetricData] = { - metrics.get(SimpleMetricsImpl.SimpleMetricsEntity).map { allSimpleMetrics ⇒ - allSimpleMetrics.metrics.map { - case (key, snapshot) ⇒ Metric(snapshot, key.unitOfMeasurement, s"Custom/${key.name}", None) - } + def onlySimpleMetrics(kv: (Entity, EntitySnapshot)): Boolean = + kamon.metric.SingleInstrumentEntityRecorder.AllCategories.contains(kv._1.category) - } getOrElse (Map.empty) + def toNewRelicMetric(kv: (Entity, EntitySnapshot)): (MetricID, MetricData) = { + val (entity, entitySnapshot) = kv + val (metricKey, instrumentSnapshot) = entitySnapshot.metrics.head + + Metric(instrumentSnapshot, metricKey.unitOfMeasurement, s"Custom/${entity.name}", None) + } + + metrics.filter(onlySimpleMetrics).map(toNewRelicMetric) } } |