diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-27 11:45:44 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2017-06-27 11:45:44 +0200 |
commit | 7d79ec25e8d08b5f058f6d7f06725311bb37dbf5 (patch) | |
tree | 1eba2162bbb8ef8523724f15e7235ded804d2101 | |
parent | bbfaf15be35a8043ffc43a887e7be1752ad044d2 (diff) | |
download | Kamon-7d79ec25e8d08b5f058f6d7f06725311bb37dbf5.tar.gz Kamon-7d79ec25e8d08b5f058f6d7f06725311bb37dbf5.tar.bz2 Kamon-7d79ec25e8d08b5f058f6d7f06725311bb37dbf5.zip |
add lowest discernible value test
-rw-r--r-- | kamon-core/src/main/scala/kamon/metric/DynamicRange.scala | 2 | ||||
-rw-r--r-- | kamon-core/src/test/scala/kamon/metric/HistogramSpec.scala | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/kamon-core/src/main/scala/kamon/metric/DynamicRange.scala b/kamon-core/src/main/scala/kamon/metric/DynamicRange.scala index c2391b45..bda7b7a5 100644 --- a/kamon-core/src/main/scala/kamon/metric/DynamicRange.scala +++ b/kamon-core/src/main/scala/kamon/metric/DynamicRange.scala @@ -21,7 +21,7 @@ case class DynamicRange(lowestDiscernibleValue: Long, highestTrackableValue: Lon def upTo(highestTrackableValue: Long): DynamicRange = copy(highestTrackableValue = highestTrackableValue) - def startingFrom(lowestDiscernibleValue: Long): DynamicRange = + def withLowestDiscernibleValue(lowestDiscernibleValue: Long): DynamicRange = copy(lowestDiscernibleValue = lowestDiscernibleValue) } 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) |