diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-04-27 23:48:39 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-04-27 23:48:39 +0200 |
commit | f5e70695ad0124cd5cd648d186d5174c7b121266 (patch) | |
tree | 0f0f86af677653ce45435c127c545656f45e81df /kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala | |
parent | 0fe9e267c7cec7a176fc8b0a43e73e12b6606b9f (diff) | |
download | Kamon-f5e70695ad0124cd5cd648d186d5174c7b121266.tar.gz Kamon-f5e70695ad0124cd5cd648d186d5174c7b121266.tar.bz2 Kamon-f5e70695ad0124cd5cd648d186d5174c7b121266.zip |
implement HdrHistogram and Distribution snapshots
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala b/kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala new file mode 100644 index 00000000..ebb82040 --- /dev/null +++ b/kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala @@ -0,0 +1,40 @@ +package org.HdrHistogram + +import java.nio.ByteBuffer +import java.util.concurrent.atomic.AtomicLongArray + +import kamon.metric.instrument.DynamicRange + +/** + * This class exposes package-private members of the [[AtomicHistogram]] class that are required to properly generate + * snapshots of our HdrHistogram implementation. + */ +abstract class AtomicHistogramExtension(dr: DynamicRange) + extends AtomicHistogram(dr.lowestDiscernibleValue, dr.highestTrackableValue, dr.significantValueDigits) { + + override def incrementTotalCount(): Unit = {} + override def addToTotalCount(value: Long): Unit = {} + + def countsArray(): AtomicLongArray = counts + def protectedUnitMagnitude(): Int = unitMagnitude + def protectedSubBucketHalfCount(): Int = subBucketHalfCount + def protectedSubBucketHalfCountMagnitude(): Int = subBucketHalfCountMagnitude +} + +/** + * Exposes the package-private members of [[ZigZagEncoding]]. + */ +object ZigZag { + def putLong(buffer: ByteBuffer, value: Long): Unit = + ZigZagEncoding.putLong(buffer, value) + + def getLong(buffer: ByteBuffer): Long = + ZigZagEncoding.getLong(buffer) + + def putInt(buffer: ByteBuffer, value: Int): Unit = + ZigZagEncoding.putInt(buffer, value) + + def getInt(buffer: ByteBuffer): Int = + ZigZagEncoding.getInt(buffer) +} + |