diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2013-11-25 02:39:24 -0300 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2013-11-25 02:39:24 -0300 |
commit | bc24dc67a0e0bacf62ef040d991b25d28e4c4a2b (patch) | |
tree | c3d80642d22bfbb27b98d20e7e6631a45f79efb0 /kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala | |
parent | 0ffbf436a7d9d69c2292c9892e740b592dc8d85e (diff) | |
download | Kamon-bc24dc67a0e0bacf62ef040d991b25d28e4c4a2b.tar.gz Kamon-bc24dc67a0e0bacf62ef040d991b25d28e4c4a2b.tar.bz2 Kamon-bc24dc67a0e0bacf62ef040d991b25d28e4c4a2b.zip |
relocate ask pattern tracing
Diffstat (limited to 'kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala')
-rw-r--r-- | kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala b/kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala new file mode 100644 index 00000000..d4f8896b --- /dev/null +++ b/kamon-trace/src/main/scala/akka/pattern/AskPatternTracing.scala @@ -0,0 +1,33 @@ +package akka.pattern + +import org.aspectj.lang.annotation.{AfterReturning, Pointcut, Aspect} +import akka.event.Logging.Warning +import scala.compat.Platform.EOL +import akka.actor.ActorRefProvider + +@Aspect +class AskPatternTracing { + + class StackTraceCaptureException extends Throwable + + @Pointcut(value = "execution(* akka.pattern.PromiseActorRef$.apply(..)) && args(provider, *)", argNames = "provider") + def promiseActorRefApply(provider: ActorRefProvider): Unit = { + provider.settings.config.getBoolean("kamon.trace.ask-pattern-tracing") + } + + @AfterReturning(pointcut = "promiseActorRefApply(provider)", returning = "promiseActor") + def hookAskTimeoutWarning(provider: ActorRefProvider, promiseActor: PromiseActorRef): Unit = { + val future = promiseActor.result.future + val system = promiseActor.provider.guardian.underlying.system + implicit val ec = system.dispatcher + val stack = new StackTraceCaptureException + + future onFailure { + case timeout: AskTimeoutException => + val stackString = stack.getStackTrace.drop(3).mkString("", EOL, EOL) + + system.eventStream.publish(Warning("AskPatternTracing", classOf[AskPatternTracing], + "Timeout triggered for ask pattern registered at: " + stackString)) + } + } +} |