diff options
author | Diego <diegolparra@gmail.com> | 2014-03-15 11:21:44 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-03-15 11:25:02 -0300 |
commit | 321191c73e6a7a3d27931386c481cc032a42c336 (patch) | |
tree | 314ea012dbbc60201a2c80c036300ba1711cf777 /kamon-core | |
parent | 54f37293b1faac5355c26a298db6b858114bc659 (diff) | |
download | Kamon-321191c73e6a7a3d27931386c481cc032a42c336.tar.gz Kamon-321191c73e6a7a3d27931386c481cc032a42c336.tar.bz2 Kamon-321191c73e6a7a3d27931386c481cc032a42c336.zip |
implementation of IMessageHandler interface in order to control Aspectj weaving messages through kamon
Diffstat (limited to 'kamon-core')
4 files changed, 67 insertions, 8 deletions
diff --git a/kamon-core/src/main/resources/META-INF/aop.xml b/kamon-core/src/main/resources/META-INF/aop.xml index e7c5836a..f5babd54 100644 --- a/kamon-core/src/main/resources/META-INF/aop.xml +++ b/kamon-core/src/main/resources/META-INF/aop.xml @@ -17,7 +17,7 @@ <aspect name="akka.instrumentation.AskPatternTracing"/> </aspects> - <weaver options="-verbose -showWeaveInfo"> + <weaver options="-XmessageHandlerClass:kamon.weaver.logging.KamonWeaverMessageHandler"> <include within="scala.concurrent..*"/> <include within="akka..*"/> <include within="spray..*"/> diff --git a/kamon-core/src/main/resources/reference.conf b/kamon-core/src/main/resources/reference.conf index a6dd6c15..706132bd 100644 --- a/kamon-core/src/main/resources/reference.conf +++ b/kamon-core/src/main/resources/reference.conf @@ -23,8 +23,6 @@ kamon { } ] - - precision { actor { processing-time { @@ -52,12 +50,16 @@ kamon { } } } - - - } trace { ask-pattern-tracing = off } + + weaver { + showWeaveInfo = off + verbose = off + debug = off + showWarn = off + } }
\ No newline at end of file diff --git a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala index 3ed2e63e..c79f980c 100644 --- a/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala +++ b/kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala @@ -22,7 +22,6 @@ import akka.dispatch.{ Envelope, MessageDispatcher } import kamon.trace._ import kamon.metrics.{ ActorMetrics, Metrics } import kamon.Kamon -import kamon.trace.TraceContext import kamon.metrics.ActorMetrics.ActorMetricRecorder @Aspect("perthis(actorCellCreation(*, *, *, *, *))") @@ -45,7 +44,7 @@ class BehaviourInvokeTracing { def invokingActorBehaviourAtActorCell(cell: ActorCell, envelope: Envelope) = {} @Around("invokingActorBehaviourAtActorCell(cell, envelope)") - def aroundBehaviourInvoke(pjp: ProceedingJoinPoint, cell: ActorCell, envelope: Envelope): Unit = { + def aroundBehaviourInvoke(pjp: ProceedingJoinPoint, cell: ActorCell, envelope: Envelope): Any = { val timestampBeforeProcessing = System.nanoTime() val contextAndTimestamp = envelope.asInstanceOf[TraceContextAware] diff --git a/kamon-core/src/main/scala/kamon/weaver/logging/KamonWeaverMessageHandler.scala b/kamon-core/src/main/scala/kamon/weaver/logging/KamonWeaverMessageHandler.scala new file mode 100644 index 00000000..1aa0aae0 --- /dev/null +++ b/kamon-core/src/main/scala/kamon/weaver/logging/KamonWeaverMessageHandler.scala @@ -0,0 +1,58 @@ +/* + * ========================================================================================= + * 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.weaver.logging + +import org.aspectj.bridge.{ IMessage, IMessageHandler } +import org.slf4j.LoggerFactory +import com.typesafe.config.ConfigFactory + +class KamonWeaverMessageHandler extends IMessageHandler { + import IMessage._ + + private val log = LoggerFactory.getLogger("AspectJ Weaver") + private val conf = ConfigFactory.load().getConfig("kamon.weaver") + + private val isVerbose = conf.getBoolean("verbose") + private val isDebug = conf.getBoolean("debug") + private val showWeaveInfo = conf.getBoolean("showWeaveInfo") + private val showWarn = conf.getBoolean("showWarn") + + def handleMessage(message: IMessage) = message.getKind match { + case WEAVEINFO if showWeaveInfo ⇒ showMessage(message) + case DEBUG if isDebug ⇒ showMessage(message) + case WARNING if showWarn ⇒ showMessage(message) + case DEBUG if isDebug ⇒ showMessage(message) + case INFO if isVerbose ⇒ showMessage(message) + case ERROR ⇒ showErrorMessage(message) + case _ ⇒ false + } + + def isIgnoring(kind: IMessage.Kind): Boolean = false // We want to see everything. + def dontIgnore(kind: IMessage.Kind) = {} + def ignore(kind: IMessage.Kind) = {} + + private def showMessage(msg: IMessage): Boolean = { + log.info(msg.getMessage) + true + } + + private def showErrorMessage(msg: IMessage): Boolean = { + log.error(msg.getMessage) + true + } +} + |