From 91b01c6bdc905db9db7874fb0a66574463a0d484 Mon Sep 17 00:00:00 2001 From: Ivan Topolnjak Date: Fri, 2 Feb 2018 03:35:02 +0100 Subject: allow arbitrary header names for automatic broadcast string keys --- kamon-core-tests/src/test/resources/reference.conf | 5 +++++ .../src/test/scala/kamon/context/ContextCodecSpec.scala | 8 ++++++++ 2 files changed, 13 insertions(+) (limited to 'kamon-core-tests') diff --git a/kamon-core-tests/src/test/resources/reference.conf b/kamon-core-tests/src/test/resources/reference.conf index e69de29b..0d7ae9e2 100644 --- a/kamon-core-tests/src/test/resources/reference.conf +++ b/kamon-core-tests/src/test/resources/reference.conf @@ -0,0 +1,5 @@ +kamon { + context.codecs.string-keys { + request-id = "X-Request-ID" + } +} \ No newline at end of file diff --git a/kamon-core-tests/src/test/scala/kamon/context/ContextCodecSpec.scala b/kamon-core-tests/src/test/scala/kamon/context/ContextCodecSpec.scala index bc46c998..f7bd7e56 100644 --- a/kamon-core-tests/src/test/scala/kamon/context/ContextCodecSpec.scala +++ b/kamon-core-tests/src/test/scala/kamon/context/ContextCodecSpec.scala @@ -48,6 +48,14 @@ class ContextCodecSpec extends WordSpec with Matchers with ContextTesting with O decodedContext.get(StringKey) shouldBe empty decodedContext.get(StringBroadcastKey).value shouldBe "this-should-be-round-tripped" } + + "read string broadcast keys using the configured header name" in { + val textMap = TextMap.Default() + textMap.put("X-Request-ID", "123456") + val decodedContext = ContextCodec.HttpHeaders.decode(textMap) + + decodedContext.get(Key.broadcastString("request-id")).value shouldBe "123456" + } } "encoding/decoding to Binary" should { -- cgit v1.2.3