diff options
Diffstat (limited to 'kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala index 9a50e149..ff71cd56 100644 --- a/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/instrument/HistogramSpec.scala @@ -48,7 +48,7 @@ class HistogramSpec extends WordSpec with Matchers { } "produce a snapshot" which { - "supports min, max, percentile, sum and numberOfMeasurements operations" in new HistogramFixture { + "supports min, max, percentile, sum, numberOfMeasurements and recordsIterator operations" in new HistogramFixture { histogram.record(100) histogram.record(200, count = 200) histogram.record(300) @@ -64,6 +64,36 @@ class HistogramSpec extends WordSpec with Matchers { snapshot.sum should be(41300) snapshot.numberOfMeasurements should be(203) + val records = snapshot.recordsIterator.map(r => r.level -> r.count).toSeq + records.size should be (4) + records(0) should be(100 -> 1) + records(1) should be(200 -> 200) + records(2) should be(300 -> 1) + records(3) should be(900 -> 1) + } + + "can be scaled" in new HistogramFixture { + histogram.record(100) + histogram.record(200, count = 200) + histogram.record(300) + histogram.record(900) + + val snapshot = takeSnapshot().scale(Time.Seconds, Time.Milliseconds) + + snapshot.min should equal(100000L +- 1000L) + snapshot.max should equal(900000L +- 9000L) + snapshot.percentile(50.0D) should be(200000) + snapshot.percentile(99.5D) should be(300000) + snapshot.percentile(99.9D) should be(900000) + snapshot.sum should be(41300000) + snapshot.numberOfMeasurements should be(203) + + val records = snapshot.recordsIterator.map(r => r.level -> r.count).toSeq + records.size should be (4) + records(0) should be(100000 -> 1) + records(1) should be(200000 -> 200) + records(2) should be(300000 -> 1) + records(3) should be(900000 -> 1) } "can be merged with another snapshot" in new MultipleHistogramFixture { |