diff options
Diffstat (limited to 'kamon-newrelic/src')
3 files changed, 14 insertions, 13 deletions
diff --git a/kamon-newrelic/src/main/resources/reference.conf b/kamon-newrelic/src/main/resources/reference.conf index 24522d63..13aaca2f 100644 --- a/kamon-newrelic/src/main/resources/reference.conf +++ b/kamon-newrelic/src/main/resources/reference.conf @@ -7,7 +7,7 @@ kamon { apdexT = 1 second app-name = "Kamon[Development]" - license-key = 2e24765acb032cb9e7207013b5ba3e2ab7d2d75c + license-key = e7d350b14228f3d28f35bc3140df2c3e565ea5d5 } } diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala index 85861454..d83e0335 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelic.scala @@ -26,11 +26,12 @@ import java.util.concurrent.TimeUnit.MILLISECONDS class NewRelicExtension(system: ExtendedActorSystem) extends Kamon.Extension { val config = system.settings.config.getConfig("kamon.newrelic") + val collectionContext = Kamon(Metrics)(system).buildDefaultCollectionContext val metricsListener = system.actorOf(Props[NewRelicMetricsListener], "kamon-newrelic") val apdexT: Double = config.getDuration("apdexT", MILLISECONDS) / 1E3 // scale to seconds. Kamon(Metrics)(system).subscribe(TraceMetrics, "*", metricsListener, permanently = true) - //Kamon(Metrics)(system).subscribe(UserMetrics, "*", metricsListener, permanently = true) + Kamon(Metrics)(system).subscribe(UserMetrics.category, "*", metricsListener, permanently = true) } class NewRelicMetricsListener extends Actor with ActorLogging { @@ -61,6 +62,5 @@ object NewRelic extends ExtensionId[NewRelicExtension] with ExtensionIdProvider math.max(max, that.max), sumOfSquares + that.sumOfSquares) } - } }
\ No newline at end of file diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala index 38517e10..a8c54684 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/WebTransactionMetrics.scala @@ -20,25 +20,28 @@ import kamon.metric._ import kamon.metric.TraceMetrics.ElapsedTime import akka.actor.Actor import kamon.Kamon +import kamon.metric.instrument.Histogram trait WebTransactionMetrics { self: Actor ⇒ def collectWebTransactionMetrics(metrics: Map[MetricGroupIdentity, MetricGroupSnapshot]): Seq[NewRelic.Metric] = { - val apdexBuilder = new ApdexBuilder("Apdex", None, Kamon(NewRelic)(context.system).apdexT) + val newRelicExtension = Kamon(NewRelic)(context.system) + val apdexBuilder = new ApdexBuilder("Apdex", None, newRelicExtension.apdexT) + val collectionContext = newRelicExtension.collectionContext - /* // Trace metrics are recorded in nanoseconds. - var accumulatedHttpDispatcher: MetricSnapshotLike = MetricSnapshot(InstrumentTypes.Histogram, 0, Scale.Nano, Vector.empty) + var accumulatedHttpDispatcher: Histogram.Snapshot = Histogram.Snapshot.empty(Scale.Nano) val webTransactionMetrics = metrics.collect { case (TraceMetrics(name), groupSnapshot) ⇒ groupSnapshot.metrics collect { - case (ElapsedTime, snapshot) ⇒ - accumulatedHttpDispatcher = accumulatedHttpDispatcher.merge(snapshot) - snapshot.measurements.foreach(level ⇒ - apdexBuilder.record(Scale.convert(snapshot.scale, Scale.Unit, level.value), level.count)) + case (ElapsedTime, snapshot: Histogram.Snapshot) ⇒ + accumulatedHttpDispatcher = accumulatedHttpDispatcher.merge(snapshot, collectionContext) + snapshot.recordsIterator.foreach { record ⇒ + apdexBuilder.record(Scale.convert(snapshot.scale, Scale.Unit, record.level), record.count) + } toNewRelicMetric(Scale.Unit)(s"WebTransaction/Custom/$name", None, snapshot) } @@ -47,9 +50,7 @@ trait WebTransactionMetrics { val httpDispatcher = toNewRelicMetric(Scale.Unit)("HttpDispatcher", None, accumulatedHttpDispatcher) val webTransaction = toNewRelicMetric(Scale.Unit)("WebTransaction", None, accumulatedHttpDispatcher) - Seq(httpDispatcher, webTransaction, apdexBuilder.build) ++ webTransactionMetrics.flatten.toSeq */ - - ??? + Seq(httpDispatcher, webTransaction, apdexBuilder.build) ++ webTransactionMetrics.flatten.toSeq } } |