diff options
Diffstat (limited to 'kamon-core/src/main/scala/kamon/metric')
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/Histogram.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/Histogram.scala b/kamon-core/src/main/scala/kamon/metric/Histogram.scala index 592dae7d..f06e58c4 100644 --- a/kamon-core/src/main/scala/kamon/metric/Histogram.scala +++ b/kamon-core/src/main/scala/kamon/metric/Histogram.scala @@ -117,7 +117,7 @@ private[kamon] trait SnapshotCreation { val zigZagCounts = Array.ofDim[Byte](buffer.limit()) buffer.get(zigZagCounts) - val distribution = new ZigZagCountsDistribution(totalCount, minIndex, maxIndex, ByteBuffer.wrap(zigZagCounts), + val distribution = new ZigZagCountsDistribution(totalCount, minIndex, maxIndex, ByteBuffer.wrap(zigZagCounts).asReadOnlyBuffer(), protectedUnitMagnitude(), protectedSubBucketHalfCount(), protectedSubBucketHalfCountMagnitude()) MetricDistribution(name, tags, unit, dynamicRange, distribution) @@ -130,7 +130,7 @@ private[kamon] object SnapshotCreation { override def initialValue(): ByteBuffer = ByteBuffer.allocate(33792) } - class ZigZagCountsDistribution(val count: Long, minIndex: Int, maxIndex: Int, val zigZagCounts: ByteBuffer, + class ZigZagCountsDistribution(val count: Long, minIndex: Int, maxIndex: Int, zigZagCounts: ByteBuffer, unitMagnitude: Int, subBucketHalfCount: Int, subBucketHalfCountMagnitude: Int) extends Distribution { val min: Long = if(count == 0) 0 else bucketValueAtIndex(minIndex) @@ -211,6 +211,10 @@ private[kamon] object SnapshotCreation { builder.result() } + def countsArray(): ByteBuffer = { + zigZagCounts.duplicate() + } + @inline private def bucketValueAtIndex(index: Int): Long = { var bucketIndex: Int = (index >> subBucketHalfCountMagnitude) - 1 var subBucketIndex: Int = (index & (subBucketHalfCount - 1)) + subBucketHalfCount |