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 | 55b3675a0b699c7a206131aea5bed6f4020c6906 (patch) | |
tree | b9050c50461810c6c54f89a1fff03dacce87cda7 | |
parent | a626bb7de87918759a5023a03679acc5e356541e (diff) | |
download | Kamon-55b3675a0b699c7a206131aea5bed6f4020c6906.tar.gz Kamon-55b3675a0b699c7a206131aea5bed6f4020c6906.tar.bz2 Kamon-55b3675a0b699c7a206131aea5bed6f4020c6906.zip |
= core: workaround border cases where mailbox size counting might fall bellow zero
-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) } } |