diff options
Diffstat (limited to 'kamon-core')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala b/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala index ea5a9b41..d711867e 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/Gauge.scala @@ -56,11 +56,14 @@ class DifferentialValueCollector(wrappedValueCollector: CurrentValueCollector) e def currentValue: Long = { if (_readAtLeastOnce) { val wrappedCurrent = wrappedValueCollector.currentValue - wrappedCurrent - _lastObservedValue.getAndSet(wrappedCurrent) + val diff = wrappedCurrent - _lastObservedValue.getAndSet(wrappedCurrent) + + if(diff >= 0) diff else 0L + } else { _lastObservedValue.set(wrappedValueCollector.currentValue) _readAtLeastOnce = true - 0 + 0L } } |