aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala')
-rw-r--r--kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala b/kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala
index ee0de53b..a582a2ae 100644
--- a/kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala
+++ b/kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala
@@ -33,6 +33,31 @@ class HistogramSpec extends WordSpec with Matchers {
emptyDistribution.buckets.length shouldBe 0
}
+ "accept a smallest discernible value configuration" in {
+ // The lowestDiscernibleValue gets rounded down to the closest power of 2, so, here it will be 64.
+ val histogram = Kamon.histogram("test-lowest-discernible-value", unit = time.nanoseconds, dynamicRange = DynamicRange.Fine.withLowestDiscernibleValue(100))
+ histogram.record(100)
+ histogram.record(200)
+ histogram.record(300)
+ histogram.record(1000)
+ histogram.record(2000)
+ histogram.record(3000)
+
+ val distribution = histogram.distribution()
+ distribution.min shouldBe(64)
+ distribution.max shouldBe(2944)
+ distribution.count shouldBe(6)
+ distribution.buckets.length shouldBe 6
+ distribution.buckets.map(b => (b.value, b.frequency)) should contain.allOf(
+ (64 -> 1),
+ (192 -> 1),
+ (256 -> 1),
+ (960 -> 1),
+ (1984 -> 1),
+ (2944 -> 1)
+ )
+ }
+
"[private api] record values and optionally keep the internal state when a snapshot is taken" in {
val histogram = Kamon.histogram("test", unit = time.nanoseconds)
histogram.record(100)