diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2018-10-30 17:24:54 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2018-10-30 17:24:54 +0100 |
commit | 313b7e7dac497c9563c09d7c8a47af8353e3e6c9 (patch) | |
tree | 212b2babdfa7cf759f7562dbc7c26e363073dcfb /kamon-core-tests | |
parent | f1c6ceffa22c59a463d6d8cd2ca77e2b440eb450 (diff) | |
download | Kamon-313b7e7dac497c9563c09d7c8a47af8353e3e6c9.tar.gz Kamon-313b7e7dac497c9563c09d7c8a47af8353e3e6c9.tar.bz2 Kamon-313b7e7dac497c9563c09d7c8a47af8353e3e6c9.zip |
include trace identifiers in HTTP responses, fixes #558
Diffstat (limited to 'kamon-core-tests')
-rw-r--r-- | kamon-core-tests/src/test/resources/reference.conf | 10 | ||||
-rw-r--r-- | kamon-core-tests/src/test/scala/kamon/instrumentation/HttpServerInstrumentationSpec.scala | 12 |
2 files changed, 20 insertions, 2 deletions
diff --git a/kamon-core-tests/src/test/resources/reference.conf b/kamon-core-tests/src/test/resources/reference.conf index c092af08..60852722 100644 --- a/kamon-core-tests/src/test/resources/reference.conf +++ b/kamon-core-tests/src/test/resources/reference.conf @@ -21,8 +21,14 @@ kamon { instrumentation { http-server { default { - tracing.preferred-trace-id-tag = "correlation-id" - tracing.tags.from-context.peer = span + tracing { + preferred-trace-id-tag = "correlation-id" + tags.from-context.peer = span + response-headers { + trace-id = "x-trace-id" + span-id = "x-span-id" + } + } } no-span-metrics { diff --git a/kamon-core-tests/src/test/scala/kamon/instrumentation/HttpServerInstrumentationSpec.scala b/kamon-core-tests/src/test/scala/kamon/instrumentation/HttpServerInstrumentationSpec.scala index c3c5f131..62eae45b 100644 --- a/kamon-core-tests/src/test/scala/kamon/instrumentation/HttpServerInstrumentationSpec.scala +++ b/kamon-core-tests/src/test/scala/kamon/instrumentation/HttpServerInstrumentationSpec.scala @@ -220,6 +220,18 @@ class HttpServerInstrumentationSpec extends WordSpec with Matchers with SpanInsp val span = inspect(handler.span) span.tag("peer").value shouldBe "superservice" } + + "write trace identifiers on the responses" in { + val handler = httpServer().receive(fakeRequest("http://localhost:8080/", "/", "GET", Map( + "x-correlation-id" -> "0011223344556677" + ))) + + val responseHeaders = mutable.Map.empty[String, String] + handler.send(fakeResponse(200, responseHeaders), handler.context) + + responseHeaders.get("x-trace-id").value shouldBe "0011223344556677" + responseHeaders.get("x-span-id") shouldBe defined + } } "all capabilities are disabled" should { |