diff options
Diffstat (limited to 'kamon-play/src/main/scala/kamon/play/instrumentation')
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala | 22 | ||||
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala | 16 |
2 files changed, 35 insertions, 3 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 c55f89e0..18060895 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -1,5 +1,5 @@ /* =================================================== - * Copyright © 2013 2014 the kamon project <http://kamon.io/> + * Copyright © 2013-2014 the kamon project <http://kamon.io/> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package kamon.play.instrumentation +import scala.concurrent.ExecutionContext.Implicits.global import kamon.trace.{ TraceRecorder, TraceContextAware } import kamon.Kamon import kamon.play.Play @@ -25,12 +26,11 @@ import akka.actor.ActorSystem import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation._ import scala.Some -import scala.concurrent.ExecutionContext.Implicits.global @Aspect class RequestInstrumentation { - @DeclareMixin("play.api.mvc.RequestHeader || play.api.test.FakeRequest") + @DeclareMixin("play.api.mvc.RequestHeader") def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default @Pointcut("execution(* play.api.GlobalSettings+.onStart(*)) && args(application)") @@ -49,6 +49,22 @@ class RequestInstrumentation { Filters(pjp.proceed(Array(next)).asInstanceOf[EssentialAction], kamonRequestFilter) } + @Pointcut("execution(* play.api.GlobalSettings+.onError(..)) && args(request, ex)") + def onError(request: TraceContextAware, ex: Throwable): Unit = {} + + @Around("onError(request, ex)") + def aroundOnError(pjp: ProceedingJoinPoint, request: TraceContextAware, ex: Throwable): Any = { + val simpleResult = request.traceContext match { + case None ⇒ pjp.proceed() + case Some(ctx) ⇒ { + val actorSystem = ctx.system + Kamon(Play)(actorSystem).publishErrorMessage(actorSystem, ex.getMessage, ex) + pjp.proceed() + } + } + simpleResult + } + private[this] val kamonRequestFilter = Filter { (nextFilter, requestHeader) ⇒ processRequest(requestHeader) 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 2fedcd70..498afc4d 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala @@ -1,3 +1,19 @@ +/* =================================================== + * Copyright © 2013-2014 the kamon project <http://kamon.io/> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + package kamon.play.instrumentation import javax.net.ssl.SSLContext |