diff options
-rw-r--r-- | kamon-play24/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala | 33 | ||||
-rw-r--r-- | kamon-play24/src/test/resources/conf/application.conf | 1 | ||||
-rw-r--r-- | kamon-play24/src/test/scala/kamon/play/RequestInstrumentationSpec.scala | 7 | ||||
-rw-r--r-- | kamon-play24/src/test/scala/kamon/play/WSInstrumentationSpec.scala | 1 | ||||
-rw-r--r-- | project/Dependencies.scala | 12 | ||||
-rw-r--r-- | project/Projects.scala | 22 | ||||
-rw-r--r-- | project/Settings.scala | 5 |
7 files changed, 38 insertions, 43 deletions
diff --git a/kamon-play24/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play24/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala index 7bf6d0d0..a1f199ba 100644 --- a/kamon-play24/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play24/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -32,7 +32,7 @@ class RequestInstrumentation { def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default @Before("call(* play.api.http.DefaultHttpRequestHandler.routeRequest(..)) && args(requestHeader)") - def beforeRouteRequest(requestHeader: RequestHeader): Unit = { + def routeRequest(requestHeader: RequestHeader): Unit = { val playExtension = Kamon(Play) val token = if (playExtension.includeTraceToken) { @@ -45,27 +45,24 @@ class RequestInstrumentation { @Around("call(* play.api.http.HttpFilters.filters(..))") def filters(pjp: ProceedingJoinPoint): Any = { val filter = new EssentialFilter { - def apply(next: EssentialAction): EssentialAction = { - val action = (requestHeader: RequestHeader) ⇒ { - val playExtension = Kamon(Play) + def apply(next: EssentialAction) = EssentialAction((requestHeader) ⇒ { + val playExtension = Kamon(Play) - def onResult(result: Result): Result = { - Tracer.currentContext.collect { ctx ⇒ - ctx.finish() - playExtension.httpServerMetrics.recordResponse(ctx.name, result.header.status.toString) + def onResult(result: Result): Result = { + Tracer.currentContext.collect { ctx ⇒ + ctx.finish() + playExtension.httpServerMetrics.recordResponse(ctx.name, result.header.status.toString) - if (playExtension.includeTraceToken) result.withHeaders(playExtension.traceTokenHeaderName -> ctx.token) - else result + if (playExtension.includeTraceToken) result.withHeaders(playExtension.traceTokenHeaderName -> ctx.token) + else result - } getOrElse result - } - //override the current trace name - Tracer.currentContext.rename(playExtension.generateTraceName(requestHeader)) - // Invoke the action - next(requestHeader).map(onResult)(SameThreadExecutionContext) + } getOrElse result } - EssentialAction(action) - } + //override the current trace name + Tracer.currentContext.rename(playExtension.generateTraceName(requestHeader)) + // Invoke the action + next(requestHeader).map(onResult)(SameThreadExecutionContext) + }) } pjp.proceed().asInstanceOf[Seq[EssentialFilter]] :+ filter } diff --git a/kamon-play24/src/test/resources/conf/application.conf b/kamon-play24/src/test/resources/conf/application.conf index b927087c..b345fca7 100644 --- a/kamon-play24/src/test/resources/conf/application.conf +++ b/kamon-play24/src/test/resources/conf/application.conf @@ -5,4 +5,3 @@ kamon { name-generator = kamon.play.DefaultNameGenerator } } - diff --git a/kamon-play24/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play24/src/test/scala/kamon/play/RequestInstrumentationSpec.scala index 8a3fef7c..9db5e20d 100644 --- a/kamon-play24/src/test/scala/kamon/play/RequestInstrumentationSpec.scala +++ b/kamon-play24/src/test/scala/kamon/play/RequestInstrumentationSpec.scala @@ -20,11 +20,10 @@ import javax.inject.Inject import kamon.Kamon import kamon.metric.instrument.CollectionContext import kamon.play.action.TraceName -import kamon.trace.TraceLocal.HttpContextKey -import kamon.trace.{ Tracer, TraceLocal } +import kamon.trace.{ TraceLocal, Tracer } import org.scalatestplus.play._ import play.api.DefaultGlobal -import play.api.http.{ HttpErrorHandler, Writeable } +import play.api.http.{ HttpErrorHandler, HttpFilters, Writeable } import play.api.libs.concurrent.Execution.Implicits.defaultContext import play.api.libs.ws.WS import play.api.mvc.Results.Ok @@ -33,7 +32,6 @@ import play.api.routing.SimpleRouter import play.api.test.Helpers._ import play.api.test._ import play.core.routing._ -import play.api.http.HttpFilters import scala.concurrent.duration._ import scala.concurrent.{ Await, Future } @@ -45,7 +43,6 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite { val executor = scala.concurrent.ExecutionContext.Implicits.global implicit override lazy val app = FakeApplication(withRoutes = { - case ("GET", "/async") ⇒ Action.async { Future { diff --git a/kamon-play24/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play24/src/test/scala/kamon/play/WSInstrumentationSpec.scala index 11d3133c..c7cc2304 100644 --- a/kamon-play24/src/test/scala/kamon/play/WSInstrumentationSpec.scala +++ b/kamon-play24/src/test/scala/kamon/play/WSInstrumentationSpec.scala @@ -16,6 +16,7 @@ package kamon.play +import kamon.Kamon import kamon.metric.{ Entity, EntitySnapshot, TraceMetrics } import kamon.trace.{ Tracer, TraceContext, SegmentCategory } import org.scalatest.{ Matchers, WordSpecLike } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 39a777d5..c57a7dfc 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -26,7 +26,7 @@ object Dependencies { val akkaVersion = "2.3.10" val aspectjVersion = "1.8.5" val slf4jVersion = "1.7.7" -// val playVersion = "2.3.8" + val playVersion = "2.3.9" val sigarVersion = "1.6.5.132" val sprayJson = "io.spray" %% "spray-json" % "1.3.1" @@ -45,9 +45,9 @@ object Dependencies { val akkaTestKit = "com.typesafe.akka" %% "akka-testkit" % akkaVersion val akkaRemote = "com.typesafe.akka" %% "akka-remote" % akkaVersion val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % akkaVersion -// val play = "com.typesafe.play" %% "play" % playVersion -// val playWS = "com.typesafe.play" %% "play-ws" % playVersion -// val playTest = "org.scalatestplus" %% "play" % "1.2.0" + val play = "com.typesafe.play" %% "play" % playVersion + val playWS = "com.typesafe.play" %% "play-ws" % playVersion + val playTest = "org.scalatestplus" %% "play" % "1.2.0" val slf4Api = "org.slf4j" % "slf4j-api" % slf4jVersion val slf4nop = "org.slf4j" % "slf4j-nop" % slf4jVersion val slf4Jul = "org.slf4j" % "jul-to-slf4j" % slf4jVersion @@ -59,8 +59,8 @@ object Dependencies { //play 2.4.x - val play24 = "com.typesafe.play" %% "play" % "2.4.0" - val playWS24 = "com.typesafe.play" %% "play-ws" % "2.4.0" + val play24 = "com.typesafe.play" %% "play" % "2.4.2" + val playWS24 = "com.typesafe.play" %% "play-ws" % "2.4.2" val playTest24 = "org.scalatestplus" %% "play" % "1.4.0-M2" val typesafeConfig = "com.typesafe" % "config" % "1.3.0" diff --git a/project/Projects.scala b/project/Projects.scala index 7a87b077..08eafae8 100644 --- a/project/Projects.scala +++ b/project/Projects.scala @@ -23,7 +23,7 @@ object Projects extends Build { lazy val kamon = Project("kamon", file(".")) .aggregate(kamonCore, kamonScala, kamonAkka, kamonSpray, kamonNewrelic, kamonPlayground, kamonTestkit, - kamonStatsD, kamonDatadog, kamonSystemMetrics, kamonLogReporter, kamonAkkaRemote, kamonJdbc, kamonAnnotation, kamonPlay24) + kamonStatsD, kamonDatadog, kamonSystemMetrics, kamonLogReporter, kamonAkkaRemote, kamonJdbc, kamonAnnotation, kamonPlay24, kamonPlay) .settings(basicSettings: _*) .settings(formatSettings: _*) .settings(noPublishing: _*) @@ -124,16 +124,16 @@ object Projects extends Build { provided(aspectJ) ++ test(slf4Api, slf4nop)) -// lazy val kamonPlay = Project("kamon-play", file("kamon-play")) -// .dependsOn(kamonCore % "compile->compile;test->test", kamonScala) -// .settings(basicSettings: _*) -// .settings(formatSettings: _*) -// .settings(aspectJSettings: _*) -// .settings( -// libraryDependencies ++= -// compile(play, playWS) ++ -// provided(aspectJ) ++ -// test(playTest, akkaTestKit, slf4Api)) + lazy val kamonPlay = Project("kamon-play", file("kamon-play")) + .dependsOn(kamonCore % "compile->compile;test->test", kamonScala) + .settings(basicSettings: _*) + .settings(formatSettings: _*) + .settings(aspectJSettings: _*) + .settings( + libraryDependencies ++= + compile(play, playWS) ++ + provided(aspectJ) ++ + test(playTest, akkaTestKit, slf4Api)) lazy val kamonPlay24 = Project("kamon-play24", file("kamon-play24")) .dependsOn(kamonCore % "compile->compile;test->test", kamonScala) diff --git a/project/Settings.scala b/project/Settings.scala index 675d99f2..fabecab5 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -26,10 +26,11 @@ import net.virtualvoid.sbt.graph.Plugin.graphSettings object Settings { val JavaVersion = "1.6" - val ScalaVersion = "2.11.5" + val ScalaVersion = "2.11.6" lazy val basicSettings = Seq( - crossScalaVersions := Seq("2.10.5", "2.11.6"), + ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }, + crossScalaVersions := Seq("2.11.6"), resolvers ++= Dependencies.resolutionRepos, fork in run := true, parallelExecution in Test := false, |