From 7d79ec25e8d08b5f058f6d7f06725311bb37dbf5 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Tue, 27 Jun 2017 11:45:44 +0200 Subject: add lowest discernible value test --- .../test/scala/kamon/metric/HistogramSpec.scala | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'kamon-core/src/test/scala/kamon') 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) -- cgit v1.2.3