diff options
author | João Ferreira <jtjeferreira@gmail.com> | 2015-05-21 20:56:42 +0100 |
---|---|---|
committer | João Ferreira <jtjeferreira@gmail.com> | 2015-05-22 11:08:02 +0100 |
commit | b927d1440f793bce669c8dc5b796f333cbd8abe6 (patch) | |
tree | 1d677ea1b30eed26796ebb634ea892e12dbf82df /kamon-spray/src/main/scala/kamon/spray | |
parent | f47cc5d6ff8e08599156c731db8a8335f6df3ada (diff) | |
download | Kamon-b927d1440f793bce669c8dc5b796f333cbd8abe6.tar.gz Kamon-b927d1440f793bce669c8dc5b796f333cbd8abe6.tar.bz2 Kamon-b927d1440f793bce669c8dc5b796f333cbd8abe6.zip |
= spray: Fix segment finishing on errors
Diffstat (limited to 'kamon-spray/src/main/scala/kamon/spray')
-rw-r--r-- | kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala index 4c408567..1950787d 100644 --- a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala +++ b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala @@ -24,7 +24,7 @@ import spray.http._ import spray.http.HttpHeaders.RawHeader import kamon.trace._ import kamon.spray.{ ClientInstrumentationLevel, Spray } -import akka.actor.ActorRef +import akka.actor.{ ActorRef, Status } import scala.concurrent.{ Future, ExecutionContext } import akka.util.Timeout @@ -87,7 +87,7 @@ class ClientRequestInstrumentation { def aroundDispatchToCommander(pjp: ProceedingJoinPoint, requestContext: TraceContextAware, message: Any): Any = { if (requestContext.traceContext.nonEmpty) { Tracer.withContext(requestContext.traceContext) { - if (message.isInstanceOf[HttpMessageEnd]) + if (message.isInstanceOf[HttpMessageEnd] || message.isInstanceOf[Status.Failure]) requestContext.asInstanceOf[SegmentAware].segment.finish() pjp.proceed() @@ -124,7 +124,7 @@ class ClientRequestInstrumentation { request.asInstanceOf[SegmentAware].segment = segment val responseFuture = originalSendReceive.apply(request) - responseFuture.map(result ⇒ segment.finish())(SameThreadExecutionContext) + responseFuture.onComplete(_ ⇒ segment.finish())(SameThreadExecutionContext) responseFuture } getOrElse originalSendReceive.apply(request) @@ -148,4 +148,4 @@ class ClientRequestInstrumentation { pjp.proceed(Array[AnyRef](request, modifiedHeaders)) } -}
\ No newline at end of file +} |