diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2017-04-18 09:50:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 09:50:09 +0200 |
commit | d5a3072d6026bfd63c20b981805a5e9047e19b90 (patch) | |
tree | ecfd21c9e899d1675366691559a16b9e1de7f84f /kamon-core/src/test | |
parent | fbff9e865d08af1207ca16876ab0f11657f3e87a (diff) | |
parent | eafc9d454afb7f8fc601a83c75a267165137b6e0 (diff) | |
download | Kamon-d5a3072d6026bfd63c20b981805a5e9047e19b90.tar.gz Kamon-d5a3072d6026bfd63c20b981805a5e9047e19b90.tar.bz2 Kamon-d5a3072d6026bfd63c20b981805a5e9047e19b90.zip |
Merge pull request #449 from jasonmartens/master
Add default metrics loaded from config
Diffstat (limited to 'kamon-core/src/test')
-rw-r--r-- | kamon-core/src/test/resources/application.conf | 11 | ||||
-rw-r--r-- | kamon-core/src/test/scala/kamon/metric/SubscriptionsProtocolSpec.scala | 31 |
2 files changed, 35 insertions, 7 deletions
diff --git a/kamon-core/src/test/resources/application.conf b/kamon-core/src/test/resources/application.conf index f79ab822..bf6123d9 100644 --- a/kamon-core/src/test/resources/application.conf +++ b/kamon-core/src/test/resources/application.conf @@ -12,4 +12,15 @@ kamon { level-of-detail = simple-trace sampling = all } + + default-tags = { + name = "jason" + number = 42 + username = ${USER} + list = [1, 2, 3] // lists do not make sense for a tag + object = { + nested-bool = true + nested-string = "a string" + } + } }
\ No newline at end of file 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) |