diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-15 11:16:21 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-15 11:16:21 +0100 |
commit | cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb (patch) | |
tree | 0f07e794e6fb88e180913a10f57ffaa4e2fa03cc /kamon-play/src/main/scala | |
parent | 8a532fc8c95a5700721248b6b4f558d9a1dcebcb (diff) | |
download | Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.tar.gz Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.tar.bz2 Kamon-cd300053cfec39dc75c1ea47b08ab5c78fe3f4bb.zip |
! core: move the TraceContext manipulation API to the Tracer companion object.
Diffstat (limited to 'kamon-play/src/main/scala')
3 files changed, 9 insertions, 10 deletions
diff --git a/kamon-play/src/main/scala/kamon/play/action/KamonTraceActions.scala b/kamon-play/src/main/scala/kamon/play/action/KamonTraceActions.scala index 715cac5e..854989a4 100644 --- a/kamon-play/src/main/scala/kamon/play/action/KamonTraceActions.scala +++ b/kamon-play/src/main/scala/kamon/play/action/KamonTraceActions.scala @@ -16,13 +16,13 @@ package kamon.play.action -import kamon.trace.TraceContext +import kamon.trace.Tracer import play.api.mvc._ import scala.concurrent.Future case class TraceName[A](name: String)(action: Action[A]) extends Action[A] { def apply(request: Request[A]): Future[Result] = { - TraceContext.currentContext.rename(name) + Tracer.currentContext.rename(name) action(request) } lazy val parser = action.parser diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala index 0ec49493..9079b391 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -16,7 +16,7 @@ package kamon.play.instrumentation import kamon.Kamon -import kamon.play.{ Play, PlayExtension } +import kamon.play.Play import kamon.trace.TraceLocal.{ HttpContextKey, HttpContext } import kamon.trace._ import org.aspectj.lang.ProceedingJoinPoint @@ -24,7 +24,6 @@ import org.aspectj.lang.annotation._ import play.api.Routes import play.api.mvc.Results._ import play.api.mvc._ -import play.libs.Akka @Aspect class RequestInstrumentation { @@ -45,7 +44,7 @@ class RequestInstrumentation { } else None val newContext = token.map(t ⇒ tracer.newContext(defaultTraceName, t)).getOrElse(tracer.newContext(defaultTraceName)) - TraceContext.setCurrentContext(newContext) + Tracer.setCurrentContext(newContext) } @Around("call(* play.api.GlobalSettings.doFilter(*)) && args(next)") @@ -56,7 +55,7 @@ class RequestInstrumentation { val executor = playExtension.defaultDispatcher def onResult(result: Result): Result = { - TraceContext.map { ctx ⇒ + Tracer.currentContext.collect { ctx ⇒ ctx.finish() recordHttpServerMetrics(result.header, ctx.name) @@ -70,7 +69,7 @@ class RequestInstrumentation { storeDiagnosticData(requestHeader) //override the current trace name - normaliseTraceName(requestHeader).map(TraceContext.currentContext.rename) + normaliseTraceName(requestHeader).map(Tracer.currentContext.rename) // Invoke the action next(requestHeader).map(onResult)(executor) @@ -80,7 +79,7 @@ class RequestInstrumentation { @Before("call(* play.api.GlobalSettings.onError(..)) && args(request, ex)") def beforeOnError(request: TraceContextAware, ex: Throwable): Unit = { - TraceContext.map { ctx ⇒ + Tracer.currentContext.collect { ctx ⇒ recordHttpServerMetrics(InternalServerError.header, ctx.name) } } 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 8b76ab8b..db95047d 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala @@ -18,7 +18,7 @@ package kamon.play.instrumentation import kamon.Kamon import kamon.play.Play -import kamon.trace.{ TraceContext, SegmentCategory } +import kamon.trace.{ Tracer, SegmentCategory } import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } import play.api.libs.ws.{ WSRequest, WSResponse } @@ -33,7 +33,7 @@ class WSInstrumentation { @Around("onExecuteRequest(request)") def aroundExecuteRequest(pjp: ProceedingJoinPoint, request: WSRequest): Any = { - TraceContext.map { ctx ⇒ + Tracer.currentContext.collect { ctx ⇒ val playExtension = Kamon(Play) val executor = playExtension.defaultDispatcher val segmentName = playExtension.generateHttpClientSegmentName(request) |