diff options
Diffstat (limited to 'kamon-spray/src/main/scala/spray/can')
-rw-r--r-- | kamon-spray/src/main/scala/spray/can/server/ServerRequestTracing.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/kamon-spray/src/main/scala/spray/can/server/ServerRequestTracing.scala b/kamon-spray/src/main/scala/spray/can/server/ServerRequestTracing.scala index 91dba87b..a7d48ac8 100644 --- a/kamon-spray/src/main/scala/spray/can/server/ServerRequestTracing.scala +++ b/kamon-spray/src/main/scala/spray/can/server/ServerRequestTracing.scala @@ -37,9 +37,16 @@ class ServerRequestTracing { @After("openRequestInit(openRequest, request)") def afterInit(openRequest: ContextAware, request: HttpRequest): Unit = { val system: ActorSystem = openRequest.asInstanceOf[OpenRequest].context.actorContext.system + val config = system.settings.config.getConfig("kamon.spray") + + val token = if(config.getBoolean("include-trace-token-header")) { + val traceTokenHeader = config.getString("trace-token-header-name") + request.headers.find(_.name == traceTokenHeader).map(_.value) + } else None + val defaultTraceName: String = request.method.value + ": " + request.uri.path - Trace.start(defaultTraceName)(system) + Trace.start(defaultTraceName, token)(system) // Necessary to force initialization of traceContext when initiating the request. openRequest.traceContext |