aboutsummaryrefslogtreecommitdiff
path: root/kamon-akka/src/main/scala/kamon/akka/instrumentation
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2015-08-28 13:02:09 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2015-08-28 13:02:09 +0200
commit110fff9745a0c1f154ee3d7a5149cd9f162a879f (patch)
tree689dc6f94cc73f7156569bf6cb69c44cda4c2c8c /kamon-akka/src/main/scala/kamon/akka/instrumentation
parentaa1c38de58d692f90275867fdfda437b99bd8dcc (diff)
downloadKamon-110fff9745a0c1f154ee3d7a5149cd9f162a879f.tar.gz
Kamon-110fff9745a0c1f154ee3d7a5149cd9f162a879f.tar.bz2
Kamon-110fff9745a0c1f154ee3d7a5149cd9f162a879f.zip
wip, core/akka/spray are kind of migrated.
Diffstat (limited to 'kamon-akka/src/main/scala/kamon/akka/instrumentation')
-rw-r--r--kamon-akka/src/main/scala/kamon/akka/instrumentation/AskPatternInstrumentation.scala24
1 files changed, 13 insertions, 11 deletions
diff --git a/kamon-akka/src/main/scala/kamon/akka/instrumentation/AskPatternInstrumentation.scala b/kamon-akka/src/main/scala/kamon/akka/instrumentation/AskPatternInstrumentation.scala
index e64b241e..64012163 100644
--- a/kamon-akka/src/main/scala/kamon/akka/instrumentation/AskPatternInstrumentation.scala
+++ b/kamon-akka/src/main/scala/kamon/akka/instrumentation/AskPatternInstrumentation.scala
@@ -17,8 +17,7 @@
package akka.kamon.instrumentation
import akka.util.Timeout
-import kamon.Kamon
-import kamon.akka.{ AkkaExtension, Akka }
+import kamon.akka.AkkaExtension
import kamon.akka.AskPatternTimeoutWarningSettings.{ Heavyweight, Lightweight, Off }
import akka.actor.{ InternalActorRef, ActorRef }
import akka.pattern.AskTimeoutException
@@ -27,11 +26,13 @@ import kamon.util.SameThreadExecutionContext
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation._
import org.aspectj.lang.reflect.SourceLocation
+import org.slf4j.LoggerFactory
import scala.concurrent.Future
import scala.compat.Platform.EOL
@Aspect
class AskPatternInstrumentation {
+ private val log = LoggerFactory.getLogger(getClass)
import AskPatternInstrumentation._
@@ -43,18 +44,19 @@ class AskPatternInstrumentation {
actor match {
// the AskPattern will only work for InternalActorRef's with these conditions.
case ref: InternalActorRef if !ref.isTerminated && timeout.duration.length > 0 && Tracer.currentContext.nonEmpty ⇒
- val akkaExtension = Kamon.extension(Akka)
val future = pjp.proceed().asInstanceOf[Future[AnyRef]]
- akkaExtension.askPatternTimeoutWarning match {
+ AkkaExtension.askPatternTimeoutWarning match {
case Off ⇒
- case Lightweight ⇒ hookLightweightWarning(future, pjp.getSourceLocation, actor, akkaExtension)
- case Heavyweight ⇒ hookHeavyweightWarning(future, new StackTraceCaptureException, actor, akkaExtension)
+ case Lightweight ⇒ hookLightweightWarning(future, pjp.getSourceLocation, actor)
+ case Heavyweight ⇒ hookHeavyweightWarning(future, new StackTraceCaptureException, actor)
}
future
- case _ ⇒ pjp.proceed().asInstanceOf[Future[AnyRef]] //
+ case _ ⇒
+ pjp.proceed().asInstanceOf[Future[AnyRef]]
+
}
def ifAskTimeoutException(code: ⇒ Unit): PartialFunction[Throwable, Unit] = {
@@ -62,21 +64,21 @@ class AskPatternInstrumentation {
case _ ⇒
}
- def hookLightweightWarning(future: Future[AnyRef], sourceLocation: SourceLocation, actor: ActorRef, akkaExtension: AkkaExtension): Unit = {
+ def hookLightweightWarning(future: Future[AnyRef], sourceLocation: SourceLocation, actor: ActorRef): Unit = {
val locationString = Option(sourceLocation)
.map(location ⇒ s"${location.getFileName}:${location.getLine}")
.getOrElse("<unknown position>")
future.onFailure(ifAskTimeoutException {
- akkaExtension.log.warning("Timeout triggered for ask pattern to actor [{}] at [{}]", actor.path.name, locationString)
+ log.warn(s"Timeout triggered for ask pattern to actor [${actor.path.name}] at [$locationString]")
})(SameThreadExecutionContext)
}
- def hookHeavyweightWarning(future: Future[AnyRef], captureException: StackTraceCaptureException, actor: ActorRef, akkaExtension: AkkaExtension): Unit = {
+ def hookHeavyweightWarning(future: Future[AnyRef], captureException: StackTraceCaptureException, actor: ActorRef): Unit = {
val locationString = captureException.getStackTrace.drop(3).mkString("", EOL, EOL)
future.onFailure(ifAskTimeoutException {
- akkaExtension.log.warning("Timeout triggered for ask pattern to actor [{}] at [{}]", actor.path.name, locationString)
+ log.warn(s"Timeout triggered for ask pattern to actor [${actor.path.name}] at [$locationString]")
})(SameThreadExecutionContext)
}
}