diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-09-10 18:35:25 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-09-10 18:35:25 -0300 |
commit | d8305b781aaf454cec558bfb86a366682e9f5eab (patch) | |
tree | d2ae762332faef33aedfaf68b1732611c4f1542d /kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala | |
parent | 218b8896f2987c43068646cea8eca597ceaf0843 (diff) | |
download | Kamon-d8305b781aaf454cec558bfb86a366682e9f5eab.tar.gz Kamon-d8305b781aaf454cec558bfb86a366682e9f5eab.tar.bz2 Kamon-d8305b781aaf454cec558bfb86a366682e9f5eab.zip |
Simple instrumentation just for keeping the uow.
Diffstat (limited to 'kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala')
-rw-r--r-- | kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala b/kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala new file mode 100644 index 00000000..4e47c2a4 --- /dev/null +++ b/kamon-core/src/main/scala/kamon/instrumentation/ActorInstrumentation.scala @@ -0,0 +1,41 @@ +package kamon.instrumentation + +import akka.actor.{Props, ActorSystem, ActorRef} +import akka.dispatch.{MessageDispatcher, Envelope} +import kamon.{Tracer, TraceContext} +import kamon.instrumentation.SimpleContextPassingInstrumentation.SimpleTraceMessage + +trait ActorInstrumentationConfiguration { + def sendMessageTransformation(from: ActorRef, to: ActorRef, message: Any): Any + def receiveInvokeInstrumentation(system: ActorSystem, self: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): ActorReceiveInvokeInstrumentation +} + + +trait ActorReceiveInvokeInstrumentation { + def preReceive(envelope: Envelope): (Envelope, Option[TraceContext]) +} + +object ActorReceiveInvokeInstrumentation { + val noopPreReceive = new ActorReceiveInvokeInstrumentation{ + def preReceive(envelope: Envelope): (Envelope, Option[TraceContext]) = (envelope, None) + } +} + +class SimpleContextPassingInstrumentation extends ActorInstrumentationConfiguration { + def sendMessageTransformation(from: ActorRef, to: ActorRef, message: Any): Any = SimpleTraceMessage(message, Tracer.context) + + def receiveInvokeInstrumentation(system: ActorSystem, self: ActorRef, props: Props, dispatcher: MessageDispatcher, parent: ActorRef): ActorReceiveInvokeInstrumentation = { + new ActorReceiveInvokeInstrumentation { + def preReceive(envelope: Envelope): (Envelope, Option[TraceContext]) = envelope match { + case env @ Envelope(SimpleTraceMessage(msg, ctx), _) => (env.copy(message = msg), ctx) + case anyOther => (anyOther, None) + } + } + } +} + +object SimpleContextPassingInstrumentation { + case class SimpleTraceMessage(message: Any, context: Option[TraceContext]) +} + + |