From 5606d35cb9f06ac655ea2abc4f0aa2e53c892b0f Mon Sep 17 00:00:00 2001 From: Carlos Ferreyra Date: Thu, 26 Dec 2013 14:39:36 -0300 Subject: Added new respondWithUow directive to add the X-UOW header back in the response. Changed ActorLogging to just propagate the trace context (does not add to the MDC anymore). Created UowConverter to let logback know where the extract the UOW from. --- kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala') diff --git a/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala b/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala index b4ff1877..44db55e7 100644 --- a/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala +++ b/kamon-spray/src/main/scala/kamon/spray/UowDirectives.scala @@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicLong import scala.util.Try import java.net.InetAddress import kamon.trace.Trace +import spray.http.HttpHeaders.RawHeader trait UowDirectives extends BasicDirectives { def uow: Directive0 = mapRequest { request ⇒ @@ -30,6 +31,7 @@ trait UowDirectives extends BasicDirectives { Trace.transformContext(_.copy(uow = generatedUow)) request } + def respondWithUow = mapHttpResponseHeaders(headers ⇒ Trace.context().map(ctx ⇒ RawHeader("X-UOW", ctx.uow) :: headers).getOrElse(headers)) } object UowDirectives { @@ -37,4 +39,4 @@ object UowDirectives { val hostnamePrefix = Try(InetAddress.getLocalHost.getHostName).getOrElse("unknown-localhost") def newUow = "%s-%s".format(hostnamePrefix, uowCounter.incrementAndGet()) -} \ No newline at end of file +} -- cgit v1.2.3