diff options
author | Ivan Topolnak <itopolnak@despegar.com> | 2014-03-07 18:08:01 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-03-11 21:14:53 -0300 |
commit | b6af84ab6b60b4ca6c0389c8c3622db3d3c27915 (patch) | |
tree | 1f89896820e36d59daadef7699b434de1051be42 /kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala | |
parent | ccbcc55282251b5e6d4f41384730232a8f0e7d05 (diff) | |
download | Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.gz Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.tar.bz2 Kamon-b6af84ab6b60b4ca6c0389c8c3622db3d3c27915.zip |
multiple fixes to the custom metrics collection facilities
Diffstat (limited to 'kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala b/kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala index f5caf6e9..1e072f71 100644 --- a/kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala +++ b/kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala @@ -23,6 +23,7 @@ import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory import kamon.Kamon import kamon.metrics.Subscriptions.TickMetricSnapshot +import kamon.metrics.MetricSnapshot.Measurement class CustomMetricSpec extends TestKitBase with WordSpecLike with Matchers { implicit lazy val system: ActorSystem = ActorSystem("actor-metrics-spec", ConfigFactory.parseString( @@ -41,20 +42,36 @@ class CustomMetricSpec extends TestKitBase with WordSpecLike with Matchers { "the Kamon custom metrics support" should { "allow registering a custom metric with the Metrics extension" in { - val recorder = Kamon(Metrics).register(CustomMetric("test/sample-counter"), CustomMetric.withConfig(100, 2)) + val recorder = Kamon(Metrics).register(CustomMetric("test/sample-counter"), CustomMetric.histogram(100, 2, Scale.Unit)) recorder should be('defined) } "allow subscriptions to custom metrics using the default subscription protocol" in { - val recorder = Kamon(Metrics).register(CustomMetric("test/sample-counter"), CustomMetric.withConfig(100, 2)) - recorder.map(_.record(100)) + val recorder = Kamon(Metrics).register(CustomMetric("test/sample-counter"), CustomMetric.histogram(100, 2, Scale.Unit)) + + recorder.map { r ⇒ + r.record(100) + r.record(15) + r.record(0) + r.record(50) + } Kamon(Metrics).subscribe(CustomMetric, "test/sample-counter", testActor) - println(within(5 seconds) { - expectMsgType[TickMetricSnapshot] - }.metrics(CustomMetric("test/sample-counter"))) + val recordedValues = within(5 seconds) { + val snapshot = expectMsgType[TickMetricSnapshot] + snapshot.metrics(CustomMetric("test/sample-counter")).metrics(CustomMetric.RecordedValues) + } + + recordedValues.min should equal(0) + recordedValues.max should equal(100) + recordedValues.numberOfMeasurements should equal(4) + recordedValues.measurements should contain allOf ( + Measurement(0, 1), + Measurement(15, 1), + Measurement(50, 1), + Measurement(100, 1)) } } |