From f3aacf437193715405efbafdd8c12f5dcb1105e0 Mon Sep 17 00:00:00 2001 From: Diego Date: Mon, 15 Sep 2014 22:35:37 -0300 Subject: = play: fixes #84 --- .../play/instrumentation/WSInstrumentation.scala | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala') 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()) } } -- cgit v1.2.3