diff options
author | Diego <diegolparra@gmail.com> | 2016-04-22 01:17:40 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2016-04-22 01:17:40 -0300 |
commit | cfcc2c6cb620073f30dd63a8b9906b91cec0d781 (patch) | |
tree | 02efa332e9cabbbd88203dd145f5073bbee31cf4 /kamon-core/src/main/scala/kamon/metric/instrument | |
parent | f4ee68b0db65e9b8940237d53b1cfde54d43531c (diff) | |
parent | 4f5bc3c5bbcddf3ea88f2573bc8021c0afd88999 (diff) | |
download | Kamon-cfcc2c6cb620073f30dd63a8b9906b91cec0d781.tar.gz Kamon-cfcc2c6cb620073f30dd63a8b9906b91cec0d781.tar.bz2 Kamon-cfcc2c6cb620073f30dd63a8b9906b91cec0d781.zip |
Merge branch 'master' of github.com:kamon-io/Kamon
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/instrument')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala b/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala index dc9a4bbf..77cb503b 100644 --- a/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala +++ b/kamon-core/src/main/scala/kamon/metric/instrument/Histogram.scala @@ -20,6 +20,7 @@ import java.nio.LongBuffer import kamon.metric.instrument.Histogram.{ DynamicRange, Snapshot } import org.HdrHistogram.ModifiedAtomicHistogram +import org.slf4j.LoggerFactory trait Histogram extends Instrument { type SnapshotType = Histogram.Snapshot @@ -135,6 +136,10 @@ object Histogram { } } +object HdrHistogram { + private val log = LoggerFactory.getLogger(classOf[HdrHistogram]) +} + /** * This implementation is meant to be used for real time data collection where data snapshots are taken often over time. * The collect(..) operation extracts all the recorded values from the histogram and resets the counts, but still @@ -142,10 +147,20 @@ object Histogram { */ class HdrHistogram(dynamicRange: DynamicRange) extends ModifiedAtomicHistogram(dynamicRange.lowestDiscernibleValue, dynamicRange.highestTrackableValue, dynamicRange.precision) with Histogram { + import HdrHistogram.log + + def record(value: Long): Unit = tryRecord(value, 1L) - def record(value: Long): Unit = recordValue(value) + def record(value: Long, count: Long): Unit = tryRecord(value, count) - def record(value: Long, count: Long): Unit = recordValueWithCount(value, count) + private def tryRecord(value: Long, count: Long): Unit = { + try { + recordValueWithCount(value, count) + } catch { + case anyException: Throwable ⇒ + log.warn("Failed to store value {} in HdrHistogram, please review your range configuration.") + } + } def collect(context: CollectionContext): Histogram.Snapshot = { import context.buffer |