diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-04-09 16:13:29 -0300 |
---|---|---|
committer | Ivan Topolnak <itopolnak@despegar.com> | 2014-04-09 16:13:29 -0300 |
commit | af11bfdbf7b452b28bd64ed560432dc0d02c85dd (patch) | |
tree | 7324c807b8ba70acacdec0e8db3a126e6bd253d6 /kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala | |
parent | 9b156f85943f96accb5b24bd54bb098cc452f7c9 (diff) | |
download | Kamon-af11bfdbf7b452b28bd64ed560432dc0d02c85dd.tar.gz Kamon-af11bfdbf7b452b28bd64ed560432dc0d02c85dd.tar.bz2 Kamon-af11bfdbf7b452b28bd64ed560432dc0d02c85dd.zip |
= core: workaround border cases where mailbox size counting might fall bellow zero
Diffstat (limited to 'kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala')
-rw-r--r-- | kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala index 85a47ee3..87ad4f92 100644 --- a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala +++ b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala @@ -59,7 +59,10 @@ class BehaviourInvokeTracing { am ⇒ am.processingTime.record(System.nanoTime() - timestampBeforeProcessing) am.timeInMailbox.record(timestampBeforeProcessing - contextAndTimestamp.captureNanoTime) - am.mailboxSize.record(cellWithMetrics.queueSize.decrementAndGet()) + + val currentMailboxSize = cellWithMetrics.queueSize.decrementAndGet() + if(currentMailboxSize >= 0) + am.mailboxSize.record(currentMailboxSize) } } } @@ -72,7 +75,9 @@ class BehaviourInvokeTracing { val cellWithMetrics = cell.asInstanceOf[ActorCellMetrics] cellWithMetrics.actorMetricsRecorder.map { am ⇒ - am.mailboxSize.record(cellWithMetrics.queueSize.incrementAndGet()) + val currentMailboxSize = cellWithMetrics.queueSize.incrementAndGet() + if(currentMailboxSize >= 0) + am.mailboxSize.record(currentMailboxSize) } } |