diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-29 03:05:08 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-29 03:05:08 +0100 |
commit | 8f8749da23afc70d89ede97537ba792a0641a528 (patch) | |
tree | 7ad75679976e571b9d64fbdc470f1c0b7d2efa69 /kamon-core/src/main/scala/kamon | |
parent | 95e17497ce7187f803626a3ae5d27fcad910b11c (diff) | |
download | Kamon-8f8749da23afc70d89ede97537ba792a0641a528.tar.gz Kamon-8f8749da23afc70d89ede97537ba792a0641a528.tar.bz2 Kamon-8f8749da23afc70d89ede97537ba792a0641a528.zip |
= core: protect against negative values on diff gauges recordings.
Diffstat (limited to 'kamon-core/src/main/scala/kamon')
-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 } } |