aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Topolnak <ivantopo@gmail.com>2013-08-13 18:50:19 -0300
committerIvan Topolnak <ivantopo@gmail.com>2013-08-13 18:50:19 -0300
commit5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf (patch)
treece063f2a917b4eb3115e718e998ad99454f54fc4
parent18656c723881ebfd8ade43a990fe73beba5690d0 (diff)
downloadKamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.tar.gz
Kamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.tar.bz2
Kamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.zip
wip
-rw-r--r--kamon-core/src/main/resources/META-INF/aop.xml1
-rw-r--r--kamon-core/src/main/resources/application.conf1
-rw-r--r--kamon-core/src/main/scala/kamon/instrumentation/ActorRefTellInstrumentation.scala24
-rw-r--r--kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala18
4 files changed, 27 insertions, 17 deletions
diff --git a/kamon-core/src/main/resources/META-INF/aop.xml b/kamon-core/src/main/resources/META-INF/aop.xml
index e6d61fa1..0f1895ec 100644
--- a/kamon-core/src/main/resources/META-INF/aop.xml
+++ b/kamon-core/src/main/resources/META-INF/aop.xml
@@ -9,6 +9,7 @@
<aspect name="kamon.instrumentation.ActorRefTellInstrumentation"/>
<aspect name="kamon.instrumentation.ActorCellInvokeInstrumentation"/>
+ <aspect name="kamon.instrumentation.UnregisteredActorRefInstrumentation"/>
<aspect name="kamon.instrumentation.RunnableInstrumentation" />
<aspect name="kamon.instrumentation.MessageQueueInstrumentation" />
diff --git a/kamon-core/src/main/resources/application.conf b/kamon-core/src/main/resources/application.conf
index 06bdf13a..1378e75e 100644
--- a/kamon-core/src/main/resources/application.conf
+++ b/kamon-core/src/main/resources/application.conf
@@ -1,7 +1,6 @@
akka {
loglevel = DEBUG
stdout-loglevel = DEBUG
- log-dead-letters = on
actor {
default-dispatcher {
fork-join-executor {
diff --git a/kamon-core/src/main/scala/kamon/instrumentation/ActorRefTellInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/ActorRefTellInstrumentation.scala
index f3e1828d..36dd9d0b 100644
--- a/kamon-core/src/main/scala/kamon/instrumentation/ActorRefTellInstrumentation.scala
+++ b/kamon-core/src/main/scala/kamon/instrumentation/ActorRefTellInstrumentation.scala
@@ -17,7 +17,7 @@ case class TraceableMessage(traceContext: Option[TraceContext], message: Any, ti
class ActorRefTellInstrumentation {
import ProceedingJoinPointPimp._
- @Pointcut("execution(* akka.actor.ScalaActorRef+.$bang(..)) && !within(akka.event.Logging.StandardOutLogger) && !within(akka.pattern.PromiseActorRef) && target(actor) && args(message, sender)")
+ @Pointcut("execution(* akka.actor.ScalaActorRef+.$bang(..)) && !within(akka.event.Logging.StandardOutLogger) && !within(akka.pattern.PromiseActorRef) && !within(akka.actor.DeadLetterActorRef) && target(actor) && args(message, sender)")
def sendingMessageToActorRef(actor: ActorRef, message: Any, sender: ActorRef) = {}
@Around("sendingMessageToActorRef(actor, message, sender)")
@@ -25,6 +25,7 @@ class ActorRefTellInstrumentation {
val actorName = MetricDirectory.nameForActor(actor)
val t = Metrics.registry.timer(actorName + "LATENCY")
+ //println(s"Wrapped message from [$sender] to [$actor] with content: [$message]")
pjp.proceedWithTarget(actor, TraceableMessage(Tracer.context, message, t.time()), sender)
}
@@ -86,31 +87,30 @@ class ActorCellInvokeInstrumentation {
case _ => pjp.proceed
}
}
+}
- @Pointcut("execution(* spray.can.server.ResponseReceiverRef.handle(*)) && args(message)")
- def sprayResponderHandle(message: AnyRef) = {}
+@Aspect
+class UnregisteredActorRefInstrumentation {
+ @Pointcut("execution(* akka.spray.UnregisteredActorRefBase+.handle(..)) && args(message, sender)")
+ def sprayResponderHandle(message: Any, sender: ActorRef) = {}
- @Around("sprayResponderHandle(message)")
- def sprayInvokeAround(pjp: ProceedingJoinPoint, message: AnyRef): Unit = {
+ @Around("sprayResponderHandle(message, sender)")
+ def sprayInvokeAround(pjp: ProceedingJoinPoint, message: Any, sender: ActorRef): Unit = {
import ProceedingJoinPointPimp._
+ println("Handling unregistered actor ref message: "+message)
message match {
case TraceableMessage(ctx, msg, timer) => {
timer.stop()
- val originalEnvelope: AnyRef = msg.asInstanceOf[AnyRef]
-
- //println("PROCESSING TIME TIMER: "+processingTimeTimer)
- val pt = processingTimeTimer.time()
ctx match {
case Some(c) => {
Tracer.set(c)
- pjp.proceedWith(originalEnvelope)
+ pjp.proceedWith(msg.asInstanceOf[AnyRef]) // TODO: define if we should use Any or AnyRef and unify with the rest of the instrumentation.
Tracer.clear
}
- case None => pjp.proceedWith(originalEnvelope)
+ case None => pjp.proceedWith(msg.asInstanceOf[AnyRef])
}
- pt.stop()
}
case _ => pjp.proceed
}
diff --git a/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala b/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala
index 2347bbe9..64c5241a 100644
--- a/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala
+++ b/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala
@@ -2,13 +2,23 @@ package kamon.logging
import akka.actor.Actor
import kamon.{Tracer, Kamon}
+import akka.event.{BusLogging, LogSource, LoggingAdapter}
trait UowActorLogging {
- self: Actor =>
+ this: Actor =>
- def logWithUOW(text: String) = {
- val uow = Tracer.context.map(_.userContext).getOrElse("NA")
- println(s"=======>[$uow] - $text")
+ val log = {
+ val (str, clazz) = LogSource(this, context.system)
+ new BusLogging(context.system.eventStream, str, clazz) with UowLoggingAdapter
}
}
+
+trait UowLoggingAdapter extends LoggingAdapter {
+ def currentUow: String = Tracer.context().flatMap(_.userContext).map(_.toString).getOrElse("")
+ protected abstract override def notifyWarning(message: String) = super.notifyWarning(s"[${currentUow}] - $message")
+ protected abstract override def notifyInfo(message: String) = super.notifyInfo( s"[${currentUow}] - $message")
+ protected abstract override def notifyDebug(message: String) = super.notifyDebug( s"[${currentUow}] - $message")
+ protected abstract override def notifyError(message: String) = super.notifyError( s"[${currentUow}] - $message")
+ protected abstract override def notifyError(cause: Throwable, message: String) = super.notifyError(cause, s"[${currentUow}] - $message")
+}