aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala')
-rw-r--r--kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala31
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)