diff options
author | pjan vandaele <pjan.vandaele@gmail.com> | 2015-06-04 15:43:48 +0900 |
---|---|---|
committer | pjan vandaele <pjan.vandaele@gmail.com> | 2015-06-04 15:48:14 +0900 |
commit | 293e502b037f930a196b8767b390b747570d0bd9 (patch) | |
tree | 8731932aba9f6f81989cbb95a73c52860ac8cf3b /kamon-akka/src/main/scala/kamon | |
parent | 57dd25e3afbfc2682b81c07161850104f32fd841 (diff) | |
download | Kamon-293e502b037f930a196b8767b390b747570d0bd9.tar.gz Kamon-293e502b037f930a196b8767b390b747570d0bd9.tar.bz2 Kamon-293e502b037f930a196b8767b390b747570d0bd9.zip |
Change map to foreach for side-effecting behaviour on Option
cleanup
Diffstat (limited to 'kamon-akka/src/main/scala/kamon')
-rw-r--r-- | kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala index bfcc0ed0..96d44166 100644 --- a/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala +++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/ActorCellInstrumentation.scala @@ -65,14 +65,14 @@ class ActorCellInstrumentation { val processingTime = System.nanoTime() - timestampBeforeProcessing val timeInMailbox = timestampBeforeProcessing - contextAndTimestamp.captureNanoTime - cellMetrics.recorder.map { am ⇒ + cellMetrics.recorder.foreach { am ⇒ am.processingTime.record(processingTime) am.timeInMailbox.record(timeInMailbox) am.mailboxSize.decrement() } // In case that this actor is behind a router, record the metrics for the router. - envelope.asInstanceOf[RouterAwareEnvelope].routerMetricsRecorder.map { rm ⇒ + envelope.asInstanceOf[RouterAwareEnvelope].routerMetricsRecorder.foreach { rm ⇒ rm.processingTime.record(processingTime) rm.timeInMailbox.record(timeInMailbox) } @@ -85,7 +85,9 @@ class ActorCellInstrumentation { @After("sendMessageInActorCell(cell, envelope)") def afterSendMessageInActorCell(cell: ActorCell, envelope: Envelope): Unit = { val cellMetrics = cell.asInstanceOf[ActorCellMetrics] - cellMetrics.recorder.map(_.mailboxSize.increment()) + cellMetrics.recorder.foreach { am ⇒ + am.mailboxSize.increment() + } } @Pointcut("execution(* akka.actor.ActorCell.stop()) && this(cell)") @@ -94,14 +96,14 @@ class ActorCellInstrumentation { @After("actorStop(cell)") def afterStop(cell: ActorCell): Unit = { val cellMetrics = cell.asInstanceOf[ActorCellMetrics] - cellMetrics.recorder.map { _ ⇒ + cellMetrics.recorder.foreach { _ ⇒ Kamon.metrics.removeEntity(cellMetrics.entity) } // The Stop can't be captured from the RoutedActorCell so we need to put this piece of cleanup here. if (cell.isInstanceOf[RoutedActorCell]) { val routedCellMetrics = cell.asInstanceOf[RoutedActorCellMetrics] - routedCellMetrics.routerRecorder.map { _ ⇒ + routedCellMetrics.routerRecorder.foreach { _ ⇒ Kamon.metrics.removeEntity(routedCellMetrics.routerEntity) } } @@ -112,8 +114,10 @@ class ActorCellInstrumentation { @Before("actorInvokeFailure(cell)") def beforeInvokeFailure(cell: ActorCell): Unit = { - val cellWithMetrics = cell.asInstanceOf[ActorCellMetrics] - cellWithMetrics.recorder.map(_.errors.increment()) + val cellMetrics = cell.asInstanceOf[ActorCellMetrics] + cellMetrics.recorder.foreach { am ⇒ + am.errors.increment() + } // In case that this actor is behind a router, count the errors for the router as well. val envelope = cell.currentMessage.asInstanceOf[RouterAwareEnvelope] @@ -121,7 +125,9 @@ class ActorCellInstrumentation { // The ActorCell.handleInvokeFailure(..) method is also called when a failure occurs // while processing a system message, in which case ActorCell.currentMessage is always // null. - envelope.routerMetricsRecorder.map(_.errors.increment()) + envelope.routerMetricsRecorder.foreach { rm ⇒ + rm.errors.increment() + } } } } @@ -162,7 +168,7 @@ class RoutedActorCellInstrumentation { } } } finally { - cellMetrics.routerRecorder map { routerRecorder ⇒ + cellMetrics.routerRecorder.foreach { routerRecorder ⇒ routerRecorder.routingTime.record(System.nanoTime() - timestampBeforeProcessing) } } |