aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala
diff options
context:
space:
mode:
authorIvan Topolnak <itopolnak@despegar.com>2014-03-07 18:08:01 -0300
committerIvan Topolnjak <ivantopo@gmail.com>2014-03-11 21:14:53 -0300
commit54f37293b1faac5355c26a298db6b858114bc659 (patch)
tree14a4a6e156d163925664753d990f7d5bbe4b4084 /kamon-core/src/test/scala/kamon/metrics/CustomMetricSpec.scala
parent60f8dd3be4593cb55e5c4023b7041ad94f6b8c8a (diff)
downloadKamon-54f37293b1faac5355c26a298db6b858114bc659.tar.gz
Kamon-54f37293b1faac5355c26a298db6b858114bc659.tar.bz2
Kamon-54f37293b1faac5355c26a298db6b858114bc659.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.scala29
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))
}
}