diff options
author | Jason Martens <jmartens@zendesk.com> | 2017-04-05 16:33:08 -0700 |
---|---|---|
committer | Jason Martens <jmartens@zendesk.com> | 2017-04-13 14:35:20 -0700 |
commit | eafc9d454afb7f8fc601a83c75a267165137b6e0 (patch) | |
tree | ecfd21c9e899d1675366691559a16b9e1de7f84f /kamon-core/src/test/scala | |
parent | fbff9e865d08af1207ca16876ab0f11657f3e87a (diff) | |
download | Kamon-eafc9d454afb7f8fc601a83c75a267165137b6e0.tar.gz Kamon-eafc9d454afb7f8fc601a83c75a267165137b6e0.tar.bz2 Kamon-eafc9d454afb7f8fc601a83c75a267165137b6e0.zip |
+ MetricsModule: Add default metrics loaded from config
Diffstat (limited to 'kamon-core/src/test/scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala index 36cc62c3..ee34acc7 100644 --- a/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala +++ b/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala @@ -36,6 +36,7 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp lazy val metricsModule = Kamon.metrics import metricsModule.{entity, subscribe, unsubscribe} + val defaultTags: Map[String, String] = Kamon.metrics.defaultTags "the Subscriptions messaging protocol" should { "allow subscribing for a single tick" in { @@ -47,12 +48,28 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp val tickSnapshot = subscriber.expectMsgType[TickMetricSnapshot] tickSnapshot.metrics.size should be(1) - tickSnapshot.metrics.keys should contain(Entity("one-shot", "trace")) + tickSnapshot.metrics.keys should contain(Entity("one-shot", "trace", defaultTags)) flushSubscriptions() subscriber.expectNoMsg(1 second) } + "subscriptions should include default tags" in { + val subscriber = TestProbe() + + Kamon.metrics.histogram("histogram-with-tags").record(1) + Kamon.metrics.subscribe("**", "**", subscriber.ref, permanently = true) + flushSubscriptions() + + val tickSubscription = subscriber.expectMsgType[TickMetricSnapshot] + tickSubscription.metrics.head._1.tags.get("name") shouldBe Some("jason") + tickSubscription.metrics.head._1.tags.get("number") shouldBe Some("42") + tickSubscription.metrics.head._1.tags.get("username").isDefined shouldBe true + tickSubscription.metrics.head._1.tags.get("object.nested-bool") shouldBe Some("true") + tickSubscription.metrics.head._1.tags.get("object.nested-string") shouldBe Some("a string") + tickSubscription.metrics.head._1.tags.get("list") shouldBe None + } + "allow subscribing permanently to a metric" in { val subscriber = TestProbe() entity(TraceMetrics, "permanent") @@ -63,7 +80,7 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp val tickSnapshot = subscriber.expectMsgType[TickMetricSnapshot] tickSnapshot.metrics.size should be(1) - tickSnapshot.metrics.keys should contain(Entity("permanent", "trace")) + tickSnapshot.metrics.keys should contain(Entity("permanent", "trace", defaultTags)) } } @@ -79,8 +96,8 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp val tickSnapshot = subscriber.expectMsgType[TickMetricSnapshot] tickSnapshot.metrics.size should be(2) - tickSnapshot.metrics.keys should contain(Entity("include-one", "trace")) - tickSnapshot.metrics.keys should contain(Entity("include-three", "trace")) + tickSnapshot.metrics.keys should contain(Entity("include-one", "trace", defaultTags)) + tickSnapshot.metrics.keys should contain(Entity("include-three", "trace", defaultTags)) } } @@ -97,8 +114,8 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp val tickSnapshot = subscriber.expectMsgType[TickMetricSnapshot] tickSnapshot.metrics.size should be(2) - tickSnapshot.metrics.keys should contain(Entity("include-one", "trace")) - tickSnapshot.metrics.keys should contain(Entity("include-three", "trace")) + tickSnapshot.metrics.keys should contain(Entity("include-one", "trace", defaultTags)) + tickSnapshot.metrics.keys should contain(Entity("include-three", "trace", defaultTags)) } } @@ -110,7 +127,7 @@ class SubscriptionsProtocolSpec extends BaseKamonSpec("subscriptions-protocol-sp flushSubscriptions() val tickSnapshot = subscriber.expectMsgType[TickMetricSnapshot] tickSnapshot.metrics.size should be(1) - tickSnapshot.metrics.keys should contain(Entity("one-shot", "trace")) + tickSnapshot.metrics.keys should contain(Entity("one-shot", "trace", defaultTags)) unsubscribe(subscriber.ref) |