diff options
-rw-r--r-- | kamon-core/src/main/resources/META-INF/aop.xml | 2 | ||||
-rw-r--r-- | kamon-core/src/main/resources/reference.conf | 12 | ||||
-rw-r--r-- | kamon-core/src/main/scala/akka/instrumentation/ActorMessagePassingTracing.scala | 3 | ||||
-rw-r--r-- | kamon-core/src/main/scala/kamon/weaver/logging/KamonWeaverMessageHandler.scala | 58 | ||||
-rw-r--r-- | kamon-play/src/main/resources/META-INF/aop.xml | 2 | ||||
-rw-r--r-- | kamon-play/src/main/scala/kamon/play/Play.scala | 2 | ||||
-rw-r--r-- | kamon-play/src/test/resources/META-INF/aop.xml | 2 | ||||
-rw-r--r-- | kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala | 20 | ||||
-rw-r--r-- | kamon-spray/src/main/resources/META-INF/aop.xml | 2 | ||||
-rw-r--r-- | kamon-testkit/src/main/resources/META-INF/aop.xml | 2 | ||||
-rw-r--r-- | project/Build.scala | 10 | ||||
-rw-r--r-- | project/Dependencies.scala | 15 | ||||
-rw-r--r-- | project/plugins.sbt | 2 |
13 files changed, 104 insertions, 28 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 + } +} + diff --git a/kamon-play/src/main/resources/META-INF/aop.xml b/kamon-play/src/main/resources/META-INF/aop.xml index 3c3cceed..ca499a33 100644 --- a/kamon-play/src/main/resources/META-INF/aop.xml +++ b/kamon-play/src/main/resources/META-INF/aop.xml @@ -6,7 +6,7 @@ <aspect name="kamon.play.instrumentation.WSInstrumentation"/> </aspects> - <weaver options="-verbose -showWeaveInfo"> + <weaver> <include within="play.api..*"/> </weaver> </aspectj> diff --git a/kamon-play/src/main/scala/kamon/play/Play.scala b/kamon-play/src/main/scala/kamon/play/Play.scala index 2e1f789f..d52de450 100644 --- a/kamon-play/src/main/scala/kamon/play/Play.scala +++ b/kamon-play/src/main/scala/kamon/play/Play.scala @@ -1,6 +1,6 @@ /* * ========================================================================================= - * Copyright © 2013 2014 the kamon project <http://kamon.io/> + * 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 diff --git a/kamon-play/src/test/resources/META-INF/aop.xml b/kamon-play/src/test/resources/META-INF/aop.xml index 63cbe8a9..2888a31a 100644 --- a/kamon-play/src/test/resources/META-INF/aop.xml +++ b/kamon-play/src/test/resources/META-INF/aop.xml @@ -5,7 +5,7 @@ <aspect name="kamon.play.instrumentation.FakeRequestIntrumentation"/> </aspects> - <weaver options="-verbose -showWeaveInfo"> + <weaver> <include within="play.api..*"/> </weaver> </aspectj> diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala index 3b8a5492..b321d123 100644 --- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala +++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala @@ -25,8 +25,10 @@ import org.junit.runner.RunWith import org.specs2.runner.JUnitRunner import play.api.test.FakeApplication import play.api.libs.ws.WS - import scala.util._ +import scala.concurrent.Await +import scala.concurrent.duration._ + @RunWith(classOf[JUnitRunner]) class WSInstrumentationSpec extends PlaySpecification { @@ -34,11 +36,19 @@ class WSInstrumentationSpec extends PlaySpecification { val appWithRoutes = FakeApplication(withRoutes = { case ("GET", "/async") ⇒ - Action.async { - WS.url("http://www.google.com").get().map { - response ⇒ - Ok(response.toString()) + Action { + val request = WS.url("http://maps.googleapis.com/maps/api/geocode/json?address=China&sensor=true").get() + + val future = request map { + response ⇒ (response.json \\ "location") } + + val result = Await.result(future, 10 seconds).asInstanceOf[List[play.api.libs.json.JsObject]] + + val latitude = (result(0) \\ "lat")(0).toString + val longitude = (result(0) \\ "lng")(0).toString + + Ok(latitude + " " + longitude) } }) diff --git a/kamon-spray/src/main/resources/META-INF/aop.xml b/kamon-spray/src/main/resources/META-INF/aop.xml index 6aacbdb3..0e5726c6 100644 --- a/kamon-spray/src/main/resources/META-INF/aop.xml +++ b/kamon-spray/src/main/resources/META-INF/aop.xml @@ -9,7 +9,7 @@ <aspect name="spray.can.client.ClientRequestInstrumentation"/> </aspects> - <weaver options="-verbose -showWeaveInfo"> + <weaver> <include within="spray.can..*"/> </weaver> </aspectj> diff --git a/kamon-testkit/src/main/resources/META-INF/aop.xml b/kamon-testkit/src/main/resources/META-INF/aop.xml index 8c5cfe42..839e8c60 100644 --- a/kamon-testkit/src/main/resources/META-INF/aop.xml +++ b/kamon-testkit/src/main/resources/META-INF/aop.xml @@ -6,7 +6,7 @@ <aspect name="akka.testkit.TestProbeInstrumentation"/> </aspects> - <weaver options="-verbose -showWeaveInfo"> + <weaver> <include within="akka..*"/> </weaver> diff --git a/project/Build.scala b/project/Build.scala index 1b9c01ca..4c29391f 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -21,7 +21,7 @@ object Build extends Build { .settings(aspectJSettings: _*) .settings( libraryDependencies ++= - compile(akkaActor, aspectJ, hdrHistogram) ++ + compile(akkaActor, aspectJ, aspectjWeaver, hdrHistogram) ++ provided(logback) ++ test(scalatest, akkaTestKit, sprayTestkit, akkaSlf4j, logback)) @@ -33,7 +33,7 @@ object Build extends Build { .settings( libraryDependencies ++= compile(akkaActor, aspectJ, sprayCan, sprayClient, sprayRouting) ++ - test(scalatest, akkaTestKit, sprayTestkit)) + test(scalatest, akkaTestKit, sprayTestkit, slf4Api, slf4nop)) .dependsOn(kamonCore, kamonTestkit) @@ -44,7 +44,7 @@ object Build extends Build { .settings( libraryDependencies ++= compile(aspectJ, sprayCan, sprayClient, sprayRouting, sprayJson, sprayJsonLenses, newrelic, snakeYaml) ++ - test(scalatest, akkaTestKit, sprayTestkit)) + test(scalatest, akkaTestKit, sprayTestkit, slf4Api, slf4nop)) .dependsOn(kamonCore) @@ -69,7 +69,7 @@ object Build extends Build { lazy val kamonTestkit = Project("kamon-testkit", file("kamon-testkit")) .settings(basicSettings: _*) .settings(formatSettings: _*) - .settings(libraryDependencies ++= compile(akkaActor, akkaTestKit)) + .settings(libraryDependencies ++= compile(akkaActor, akkaTestKit) ++ test(slf4Api, slf4nop)) .dependsOn(kamonCore) @@ -77,7 +77,7 @@ object Build extends Build { .settings(basicSettings: _*) .settings(formatSettings: _*) .settings(aspectJSettings: _*) - .settings(libraryDependencies ++= compile(playTest, aspectJ) ++ test(playTest)) + .settings(libraryDependencies ++= compile(playTest, aspectJ) ++ test(playTest, slf4Api)) .dependsOn(kamonCore) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 5e59aa4d..82375632 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,14 +8,18 @@ object Dependencies { "typesafe repo" at "http://repo.typesafe.com/typesafe/releases/" ) - val sprayVersion = "1.2.0" - val akkaVersion = "2.2.3" + val sprayVersion = "1.2.0" + val akkaVersion = "2.2.3" + val playVersion = "2.2.2" + val aspectjVersion = "1.7.4" + val slf4jVersion = "1.7.6" val sprayJson = "io.spray" %% "spray-json" % "1.2.5" val sprayJsonLenses = "net.virtual-void" %% "json-lenses" % "0.5.3" val scalatest = "org.scalatest" % "scalatest_2.10" % "2.0" val logback = "ch.qos.logback" % "logback-classic" % "1.0.13" - val aspectJ = "org.aspectj" % "aspectjrt" % "1.7.2" + val aspectJ = "org.aspectj" % "aspectjrt" % aspectjVersion + val aspectjWeaver = "org.aspectj" % "aspectjweaver" % aspectjVersion val newrelic = "com.newrelic.agent.java" % "newrelic-api" % "3.1.0" val snakeYaml = "org.yaml" % "snakeyaml" % "1.13" val hdrHistogram = "org.hdrhistogram" % "HdrHistogram" % "1.0.8" @@ -26,7 +30,10 @@ object Dependencies { val akkaActor = "com.typesafe.akka" %% "akka-actor" % akkaVersion val akkaSlf4j = "com.typesafe.akka" %% "akka-slf4j" % akkaVersion val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion - val playTest = "com.typesafe.play" %% "play-test" % "2.2.1" + val playTest = "com.typesafe.play" %% "play-test" % playVersion + val slf4Api = "org.slf4j" % "slf4j-api" % slf4jVersion + val slf4nop = "org.slf4j" % "slf4j-nop" % slf4jVersion + def compile (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile") diff --git a/project/plugins.sbt b/project/plugins.sbt index ee0b967c..33519318 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,7 +6,7 @@ addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1") addSbtPlugin("io.spray" % "sbt-revolver" % "0.6.2") -addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.4") addSbtPlugin("com.ivantopo.sbt" % "sbt-newrelic" % "0.0.1") |