diff options
Diffstat (limited to 'kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala')
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala index 14bcd8c9..87467050 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala @@ -24,7 +24,6 @@ import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } import play.api.libs.ws.ning.NingWSRequest import play.api.libs.ws.{ WSRequest, WSResponse } -import play.libs.Akka import scala.concurrent.Future @@ -39,18 +38,14 @@ class WSInstrumentation { import kamon.play.instrumentation.WSInstrumentation._ - TraceRecorder.currentContext match { - case ctx @ Some(_) ⇒ - TraceRecorder.withTraceContext(ctx) { - val executor = Kamon(Play)(Akka.system()).defaultDispatcher - val segmentHandle = TraceRecorder.startSegment(HttpClientRequest(request.url), basicRequestAttributes(request)) - val response = pjp.proceed().asInstanceOf[Future[WSResponse]] + TraceRecorder.currentContext.map { ctx ⇒ + val executor = Kamon(Play)(ctx.system).defaultDispatcher + val segmentHandle = TraceRecorder.startSegment(HttpClientRequest(request.url), basicRequestAttributes(request)) + val response = pjp.proceed().asInstanceOf[Future[WSResponse]] - response.map(result ⇒ segmentHandle.map(_.finish()))(executor) - response - } - case None ⇒ pjp.proceed() - } + response.map(result ⇒ segmentHandle.map(_.finish()))(executor) + response + }.getOrElse(pjp.proceed()) } } |