diff options
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala | 15 | ||||
-rw-r--r-- | kamon-play/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala | 1 |
2 files changed, 10 insertions, 6 deletions
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 527e0a9e..1ce41a75 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -34,12 +34,12 @@ class RequestInstrumentation { @DeclareMixin("play.api.mvc.RequestHeader+") def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default - @After("execution(* play.api.GlobalSettings+.onStart(*)) && args(application)") + @After("call(* play.api.GlobalSettings.onStart(*)) && args(application)") def afterApplicationStart(application: play.api.Application): Unit = { Kamon(Play)(Akka.system()) } - @Before("call(* play.api.GlobalSettings+.onRouteRequest(..)) && args(requestHeader)") + @Before("call(* play.api.GlobalSettings.onRouteRequest(..)) && args(requestHeader)") def beforeRouteRequest(requestHeader: RequestHeader): Unit = { val system = Akka.system() val playExtension = Kamon(Play)(system) @@ -52,7 +52,7 @@ class RequestInstrumentation { TraceRecorder.start(defaultTraceName, token)(system) } - @Around("execution(* play.api.GlobalSettings+.doFilter(*)) && args(next)") + @Around("call(* play.api.GlobalSettings.doFilter(*)) && args(next)") def aroundDoFilter(pjp: ProceedingJoinPoint, next: EssentialAction): Any = { val essentialAction = (requestHeader: RequestHeader) ⇒ { // TODO: Move to a Kamon-specific dispatcher. @@ -63,6 +63,7 @@ class RequestInstrumentation { ctx.finish() val playExtension = Kamon(Play)(system) + recordHttpServerMetrics(result.header, ctx.name, playExtension) if (playExtension.includeTraceToken) result.withHeaders(playExtension.traceTokenHeaderName -> ctx.token) @@ -82,9 +83,11 @@ class RequestInstrumentation { pjp.proceed(Array(EssentialAction(essentialAction))) } - @Before("execution(* play.api.GlobalSettings+.onError(..)) && args(request, ex)") - def beforeOnError(request: TraceContextAware, ex: Throwable): Unit = TraceRecorder.withTraceContextAndSystem { (ctx, system) ⇒ - recordHttpServerMetrics(InternalServerError.header, ctx.name, Kamon(Play)(system)) + @Before("call(* play.api.GlobalSettings.onError(..)) && args(request, ex)") + def beforeOnError(request: TraceContextAware, ex: Throwable): Unit = { + TraceRecorder.withTraceContextAndSystem { (ctx, system) ⇒ + recordHttpServerMetrics(InternalServerError.header, ctx.name, Kamon(Play)(system)) + } } def recordHttpServerMetrics(header: ResponseHeader, traceName: String, playExtension: PlayExtension): Unit = diff --git a/kamon-play/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala b/kamon-play/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala index 55b72908..10e285db 100644 --- a/kamon-play/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala +++ b/kamon-play/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala @@ -21,6 +21,7 @@ import kamon.trace.TraceContextAware @Aspect class FakeRequestIntrumentation { + @DeclareMixin("play.api.test.FakeRequest") def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default } |