From b6ea0a93e6be8e1f355f1bc993618d178d0c9372 Mon Sep 17 00:00:00 2001 From: Ivan Topolnak Date: Mon, 27 Jan 2014 19:09:40 -0300 Subject: first implementation of a universal metrics repository for any kind of metrics we might be interested in --- .../ActorMessagePassingTracing.scala | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala') diff --git a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala index 6cede344..68d606ba 100644 --- a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala +++ b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala @@ -20,26 +20,24 @@ import org.aspectj.lang.ProceedingJoinPoint import akka.actor.{ Cell, Props, ActorSystem, ActorRef } import akka.dispatch.{ Envelope, MessageDispatcher } import kamon.trace.{ TraceContext, ContextAware, Trace } -import kamon.metrics.{ HdrActorMetricsRecorder, ActorMetrics } +import kamon.metrics.{ ActorMetrics, HdrActorMetricsRecorder, Metrics } import kamon.Kamon +import kamon.metrics.ActorMetrics.ActorMetricRecorder @Aspect("perthis(actorCellCreation(*, *, *, *, *))") class BehaviourInvokeTracing { - var path: Option[String] = None - var actorMetrics: Option[HdrActorMetricsRecorder] = None + var path: String = _ + var actorMetrics: Option[ActorMetricRecorder] = None @Pointcut("execution(akka.actor.ActorCell.new(..)) && args(system, ref, props, dispatcher, parent)") def actorCellCreation(system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): Unit = {} @After("actorCellCreation(system, ref, props, dispatcher, parent)") def afterCreation(system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): Unit = { - val metricsExtension = Kamon(ActorMetrics)(system) - val simplePathString = ref.path.elements.mkString("/") + val metricsExtension = Kamon(Metrics)(system) - if (metricsExtension.shouldTrackActor(simplePathString)) { - path = Some(ref.path.toString) - actorMetrics = Some(metricsExtension.registerActor(simplePathString)) - } + path = ref.path.elements.mkString("/") + actorMetrics = metricsExtension.register(path, ActorMetrics) } @Pointcut("(execution(* akka.actor.ActorCell.invoke(*)) || execution(* akka.routing.RoutedActorCell.sendMessage(*))) && args(envelope)") @@ -55,8 +53,8 @@ class BehaviourInvokeTracing { } actorMetrics.map { am ⇒ - am.recordProcessingTime(System.nanoTime() - timestampBeforeProcessing) - am.recordTimeInMailbox(timestampBeforeProcessing - contextAndTimestamp.timestamp) + am.processingTime.record(System.nanoTime() - timestampBeforeProcessing) + am.timeInMailbox.record(timestampBeforeProcessing - contextAndTimestamp.timestamp) } } @@ -65,7 +63,7 @@ class BehaviourInvokeTracing { @After("actorStop(cell)") def afterStop(cell: Cell): Unit = { - path.map(p ⇒ Kamon(ActorMetrics)(cell.system).unregisterActor(p)) + actorMetrics.map(p ⇒ Kamon(Metrics)(cell.system).unregister(path, ActorMetrics)) } } -- cgit v1.2.3