aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/metric/instrument/HistogramExtension.scala
blob: ebb8204002732bc84570fda871c4052c7521c6e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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)
}