From 42e23d23ba64f570ad613bca26d930727cd77dde Mon Sep 17 00:00:00 2001 From: Ivan Topolnak Date: Wed, 9 Apr 2014 17:39:43 -0300 Subject: = core: adjust the assertions on ActorMetricsSpec accordingly to our current collection model --- .../scala/akka/instrumentation/ActorMessagePassingTracing.scala | 8 ++++---- kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala index 87ad4f92..e52a66b2 100644 --- a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala +++ b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala @@ -18,9 +18,9 @@ package akka.instrumentation import org.aspectj.lang.annotation._ import org.aspectj.lang.ProceedingJoinPoint import akka.actor._ -import akka.dispatch.{Envelope, MessageDispatcher} +import akka.dispatch.{ Envelope, MessageDispatcher } import kamon.trace._ -import kamon.metrics.{ActorMetrics, Metrics} +import kamon.metrics.{ ActorMetrics, Metrics } import kamon.Kamon import kamon.metrics.ActorMetrics.ActorMetricRecorder import java.util.concurrent.atomic.AtomicInteger @@ -61,7 +61,7 @@ class BehaviourInvokeTracing { am.timeInMailbox.record(timestampBeforeProcessing - contextAndTimestamp.captureNanoTime) val currentMailboxSize = cellWithMetrics.queueSize.decrementAndGet() - if(currentMailboxSize >= 0) + if (currentMailboxSize >= 0) am.mailboxSize.record(currentMailboxSize) } } @@ -76,7 +76,7 @@ class BehaviourInvokeTracing { cellWithMetrics.actorMetricsRecorder.map { am ⇒ val currentMailboxSize = cellWithMetrics.queueSize.incrementAndGet() - if(currentMailboxSize >= 0) + if (currentMailboxSize >= 0) am.mailboxSize.record(currentMailboxSize) } } diff --git a/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala b/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala index 29b8eafc..61d15bc9 100644 --- a/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala +++ b/kamon-core/src/test/scala/kamon/metrics/ActorMetricsSpec.scala @@ -69,12 +69,8 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers { } val actorMetrics = expectActorMetrics("user/tracked-normal-conditions", metricsListener, 3 seconds) - // Mailbox size is measured twice, on queue and dequeue, plus the automatic last-value recording. - actorMetrics.mailboxSize.numberOfMeasurements should be(21) actorMetrics.mailboxSize.max should be <= 10L - actorMetrics.processingTime.numberOfMeasurements should be(10L) - actorMetrics.timeInMailbox.numberOfMeasurements should be(10L) } @@ -92,8 +88,9 @@ class ActorMetricsSpec extends TestKitBase with WordSpecLike with Matchers { // process the tick in which the actor is stalled. val stalledTickMetrics = expectActorMetrics("user/tracked-mailbox-size-queueing-up", metricsListener, 2 seconds) stalledTickMetrics.mailboxSize.numberOfMeasurements should equal(1) - stalledTickMetrics.mailboxSize.measurements should contain only (Measurement(9, 1)) // only the automatic last-value recording - stalledTickMetrics.mailboxSize.max should equal(9) + // only the automatic last-value recording should be taken, and includes the message being currently processed. + stalledTickMetrics.mailboxSize.measurements should contain only (Measurement(10, 1)) + stalledTickMetrics.mailboxSize.max should equal(10) stalledTickMetrics.processingTime.numberOfMeasurements should be(0L) stalledTickMetrics.timeInMailbox.numberOfMeasurements should be(0L) -- cgit v1.2.3