aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Parra <diegolparra@gmail.com>2016-06-17 11:59:37 -0300
committerGitHub <noreply@github.com>2016-06-17 11:59:37 -0300
commit314ecd45e6c89d7f188645c83a5d27064cb3abb5 (patch)
tree2ca6b2ec396f8b7e30dce19643b8bd0995d250de
parent7d103e729a2e52f953c9b70c252b97fbf213603b (diff)
parent5f0f3e17a72ffd1d5af35a910e6c51dc172df01f (diff)
downloadKamon-314ecd45e6c89d7f188645c83a5d27064cb3abb5.tar.gz
Kamon-314ecd45e6c89d7f188645c83a5d27064cb3abb5.tar.bz2
Kamon-314ecd45e6c89d7f188645c83a5d27064cb3abb5.zip
Merge pull request #362 from dspasojevic/master
+ kamon-play-25: add play 2.5.x support
-rw-r--r--kamon-play-2.5.x/src/main/resources/META-INF/aop.xml13
-rw-r--r--kamon-play-2.5.x/src/main/resources/reference.conf34
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/KamonFilter.scala47
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/Play.scala76
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/action/KamonTraceActions.scala29
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/di/KamonModule.scala54
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/LoggerLikeInstrumentation.scala45
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala64
-rw-r--r--kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala44
-rw-r--r--kamon-play-2.5.x/src/test/resources/META-INF/aop.xml11
-rw-r--r--kamon-play-2.5.x/src/test/resources/conf/application.conf7
-rw-r--r--kamon-play-2.5.x/src/test/resources/logback.xml12
-rw-r--r--kamon-play-2.5.x/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala122
-rw-r--r--kamon-play-2.5.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala289
-rw-r--r--kamon-play-2.5.x/src/test/scala/kamon/play/WSInstrumentationSpec.scala96
-rw-r--r--kamon-play-2.5.x/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala27
-rw-r--r--project/Dependencies.scala6
-rw-r--r--project/Projects.scala16
-rw-r--r--project/Settings.scala3
-rw-r--r--project/plugins.sbt2
20 files changed, 995 insertions, 2 deletions
diff --git a/kamon-play-2.5.x/src/main/resources/META-INF/aop.xml b/kamon-play-2.5.x/src/main/resources/META-INF/aop.xml
new file mode 100644
index 00000000..e24d48d5
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/resources/META-INF/aop.xml
@@ -0,0 +1,13 @@
+<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
+
+<aspectj>
+ <aspects>
+ <aspect name="kamon.play.instrumentation.RequestInstrumentation"/>
+ <aspect name="kamon.play.instrumentation.WSInstrumentation"/>
+ <aspect name="kamon.play.instrumentation.LoggerLikeInstrumentation"/>
+ </aspects>
+
+ <weaver>
+ <include within="play.api..*"/>
+ </weaver>
+</aspectj>
diff --git a/kamon-play-2.5.x/src/main/resources/reference.conf b/kamon-play-2.5.x/src/main/resources/reference.conf
new file mode 100644
index 00000000..a9c33629
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/resources/reference.conf
@@ -0,0 +1,34 @@
+# ================================== #
+# Kamon-Play Reference Configuration #
+# ================================== #
+
+kamon {
+ play {
+
+ # Header name used when propagating the `TraceContext.token` value across applications.
+ trace-token-header-name = "X-Trace-Token"
+
+ # When set to true, Kamon will automatically set and propogate the `TraceContext.token` value under the following
+ # conditions:
+ # - When a server side request is received containing the trace token header, the new `TraceContext` will have that
+ # some token, and once the response to that request is ready, the trace token header is also included in the
+ # response.
+ # - When a WS client request is issued and a `TraceContext` is available, the trace token header will be included
+ # in the request headers.
+ automatic-trace-token-propagation = true
+
+ # Fully qualified name of the implementation of kamon.play.NameGenerator that will be used for assigning names
+ # to traces and client http segments.
+ name-generator = kamon.play.DefaultNameGenerator
+
+ }
+
+ modules {
+ kamon-play {
+ requires-aspectj = yes
+ }
+ }
+}
+
+#register the module with Play
+play.modules.enabled += "kamon.play.di.KamonModule"
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/KamonFilter.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/KamonFilter.scala
new file mode 100644
index 00000000..80878afe
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/KamonFilter.scala
@@ -0,0 +1,47 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2015 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.play
+
+import akka.util.ByteString
+import kamon.trace.Tracer
+import kamon.util.SameThreadExecutionContext
+import play.api.libs.streams.Accumulator
+import play.api.mvc.{ EssentialAction, EssentialFilter, RequestHeader, Result }
+
+class KamonFilter extends EssentialFilter {
+
+ override def apply(next: EssentialAction): EssentialAction = new EssentialAction {
+ override def apply(requestHeader: RequestHeader): Accumulator[ByteString, Result] = {
+
+ 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
+
+ } getOrElse result
+ }
+
+ //override the current trace name
+ Tracer.currentContext.rename(PlayExtension.generateTraceName(requestHeader))
+ val nextAccumulator = next.apply(requestHeader)
+ nextAccumulator.map(onResult)(SameThreadExecutionContext)
+ }
+ }
+
+}
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/Play.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/Play.scala
new file mode 100644
index 00000000..13c98240
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/Play.scala
@@ -0,0 +1,76 @@
+/*
+ * =========================================================================================
+ * Copyright © 2013-2015 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.play
+
+import akka.actor._
+import kamon.Kamon
+import kamon.util.http.HttpServerMetrics
+import kamon.util.logger.LazyLogger
+import play.api.libs.ws.WSRequest
+import play.api.mvc.RequestHeader
+
+object PlayExtension {
+ val SegmentLibraryName = "WS-client"
+
+ val log = LazyLogger("kamon.play.PlayExtension")
+
+ private val config = Kamon.config.getConfig("kamon.play")
+ private val dynamic = new ReflectiveDynamicAccess(getClass.getClassLoader)
+ val httpServerMetrics = Kamon.metrics.entity(HttpServerMetrics, "play-server")
+
+ val includeTraceToken: Boolean = config.getBoolean("automatic-trace-token-propagation")
+ val traceTokenHeaderName: String = config.getString("trace-token-header-name")
+
+ private val nameGeneratorFQN = config.getString("name-generator")
+ private val nameGenerator: NameGenerator = dynamic.createInstanceFor[NameGenerator](nameGeneratorFQN, Nil).get
+
+ def generateTraceName(requestHeader: RequestHeader): String = nameGenerator.generateTraceName(requestHeader)
+ def generateHttpClientSegmentName(request: WSRequest): String = nameGenerator.generateHttpClientSegmentName(request)
+}
+
+trait NameGenerator {
+ def generateTraceName(requestHeader: RequestHeader): String
+ def generateHttpClientSegmentName(request: WSRequest): String
+}
+
+class DefaultNameGenerator extends NameGenerator {
+ import scala.collection.concurrent.TrieMap
+ import play.api.routing.Router
+ import java.util.Locale
+ import kamon.util.TriemapAtomicGetOrElseUpdate.Syntax
+
+ private val cache = TrieMap.empty[String, String]
+ private val normalizePattern = """\$([^<]+)<[^>]+>""".r
+
+ def generateTraceName(requestHeader: RequestHeader): String = requestHeader.tags.get(Router.Tags.RouteVerb).map { verb ⇒
+ val path = requestHeader.tags(Router.Tags.RoutePattern)
+ cache.atomicGetOrElseUpdate(s"$verb$path", {
+ val traceName = {
+ // Convert paths of form GET /foo/bar/$paramname<regexp>/blah to foo.bar.paramname.blah.get
+ val p = normalizePattern.replaceAllIn(path, "$1").replace('/', '.').dropWhile(_ == '.')
+ val normalisedPath = {
+ if (p.lastOption.exists(_ != '.')) s"$p."
+ else p
+ }
+ s"$normalisedPath${verb.toLowerCase(Locale.ENGLISH)}"
+ }
+ traceName
+ })
+ } getOrElse "UntaggedTrace"
+
+ def generateHttpClientSegmentName(request: WSRequest): String = request.uri.getAuthority
+}
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/action/KamonTraceActions.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/action/KamonTraceActions.scala
new file mode 100644
index 00000000..72308b35
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/action/KamonTraceActions.scala
@@ -0,0 +1,29 @@
+/* ===================================================
+ * Copyright © 2013-2015 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.play.action
+
+import kamon.trace.Tracer
+import play.api.mvc._
+import scala.concurrent.Future
+
+case class TraceName[A](name: String)(action: Action[A]) extends Action[A] {
+ def apply(request: Request[A]): Future[Result] = {
+ Tracer.currentContext.rename(name)
+ action(request)
+ }
+ lazy val parser = action.parser
+}
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/di/KamonModule.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/di/KamonModule.scala
new file mode 100644
index 00000000..372e7300
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/di/KamonModule.scala
@@ -0,0 +1,54 @@
+/* =========================================================================================
+ * Copyright © 2013-2015 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.play.di
+
+import javax.inject._
+import kamon.metric.MetricsModule
+import kamon.trace.TracerModule
+import play.api.inject.{ ApplicationLifecycle, Module }
+import play.api.{ Logger, Configuration, Environment }
+import scala.concurrent.Future
+
+trait Kamon {
+ def start(): Unit
+ def shutdown(): Unit
+ def metrics(): MetricsModule
+ def tracer(): TracerModule
+}
+
+class KamonModule extends Module {
+ def bindings(environment: Environment, configuration: Configuration) = {
+ Seq(bind[Kamon].to[KamonAPI].eagerly())
+ }
+}
+
+@Singleton
+class KamonAPI @Inject() (lifecycle: ApplicationLifecycle, environment: Environment) extends Kamon {
+ private val log = Logger(classOf[KamonAPI])
+
+ log.info("Registering the Kamon Play Module.")
+
+ start() //force to start kamon eagerly on application startup
+
+ def start(): Unit = kamon.Kamon.start()
+ def shutdown(): Unit = kamon.Kamon.shutdown()
+ def metrics(): MetricsModule = kamon.Kamon.metrics
+ def tracer(): TracerModule = kamon.Kamon.tracer
+
+ lifecycle.addStopHook { () ⇒
+ Future.successful(shutdown())
+ }
+}
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/LoggerLikeInstrumentation.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/LoggerLikeInstrumentation.scala
new file mode 100644
index 00000000..0cdc50f2
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/LoggerLikeInstrumentation.scala
@@ -0,0 +1,45 @@
+/* =========================================================================================
+ * Copyright © 2013-2015 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.play.instrumentation
+
+import kamon.trace.logging.MdcKeysSupport
+import org.aspectj.lang.ProceedingJoinPoint
+import org.aspectj.lang.annotation._
+
+@Aspect
+class LoggerLikeInstrumentation extends MdcKeysSupport {
+
+ @Pointcut("execution(* play.api.LoggerLike+.info(..))")
+ def infoPointcut(): Unit = {}
+
+ @Pointcut("execution(* play.api.LoggerLike+.debug(..))")
+ def debugPointcut(): Unit = {}
+
+ @Pointcut("execution(* play.api.LoggerLike+.warn(..))")
+ def warnPointcut(): Unit = {}
+
+ @Pointcut("execution(* play.api.LoggerLike+.error(..))")
+ def errorPointcut(): Unit = {}
+
+ @Pointcut("execution(* play.api.LoggerLike+.trace(..))")
+ def tracePointcut(): Unit = {}
+
+ @Around("(infoPointcut() || debugPointcut() || warnPointcut() || errorPointcut() || tracePointcut())")
+ def aroundLog(pjp: ProceedingJoinPoint): Any = withMdc {
+ pjp.proceed()
+ }
+}
+
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala
new file mode 100644
index 00000000..946c16be
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala
@@ -0,0 +1,64 @@
+/* =========================================================================================
+ * Copyright © 2013-2015 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.play.instrumentation
+
+import akka.util.ByteString
+import kamon.Kamon.tracer
+import kamon.play.{ KamonFilter, PlayExtension }
+import kamon.trace._
+import kamon.util.SameThreadExecutionContext
+import org.aspectj.lang.ProceedingJoinPoint
+import org.aspectj.lang.annotation._
+import play.api.libs.streams.Accumulator
+import play.api.mvc.Results._
+import play.api.mvc.{ EssentialFilter, _ }
+
+@Aspect
+class RequestInstrumentation {
+
+ private lazy val filter: EssentialFilter = new KamonFilter()
+
+ @DeclareMixin("play.api.mvc.RequestHeader+")
+ def mixinContextAwareToRequestHeader: TraceContextAware = TraceContextAware.default
+
+ @Before("call(* play.api.http.DefaultHttpRequestHandler.routeRequest(..)) && args(requestHeader)")
+ def routeRequest(requestHeader: RequestHeader): Unit = {
+ val token = if (PlayExtension.includeTraceToken) {
+ requestHeader.headers.get(PlayExtension.traceTokenHeaderName)
+ } else None
+
+ Tracer.setCurrentContext(tracer.newContext("UnnamedTrace", token))
+ }
+
+ @Around("call(* play.api.http.HttpFilters.filters(..))")
+ def filters(pjp: ProceedingJoinPoint): Any = {
+ pjp.proceed().asInstanceOf[Seq[EssentialFilter]] :+ filter
+ }
+
+ @Before("call(* play.api.http.HttpErrorHandler.onClientServerError(..)) && args(requestContextAware, statusCode, *)")
+ def onClientError(requestContextAware: TraceContextAware, statusCode: Int): Unit = {
+ requestContextAware.traceContext.collect { ctx ⇒
+ PlayExtension.httpServerMetrics.recordResponse(ctx.name, statusCode.toString)
+ }
+ }
+
+ @Before("call(* play.api.http.HttpErrorHandler.onServerError(..)) && args(requestContextAware, ex)")
+ def onServerError(requestContextAware: TraceContextAware, ex: Throwable): Unit = {
+ requestContextAware.traceContext.collect { ctx ⇒
+ PlayExtension.httpServerMetrics.recordResponse(ctx.name, InternalServerError.header.status.toString)
+ }
+ }
+}
diff --git a/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala
new file mode 100644
index 00000000..b0b1dc83
--- /dev/null
+++ b/kamon-play-2.5.x/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala
@@ -0,0 +1,44 @@
+/* ===================================================
+ * Copyright © 2013-2015 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.play.instrumentation
+
+import kamon.play.PlayExtension
+import kamon.trace.{ Tracer, SegmentCategory }
+import kamon.util.SameThreadExecutionContext
+import org.aspectj.lang.ProceedingJoinPoint
+import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut }
+import play.api.libs.ws.{ WSRequest, WSResponse }
+import scala.concurrent.Future
+
+@Aspect
+class WSInstrumentation {
+
+ @Pointcut("target(request) && call(scala.concurrent.Future<play.api.libs.ws.WSResponse> execute())")
+ def onExecuteRequest(request: WSRequest): Unit = {}
+
+ @Around("onExecuteRequest(request)")
+ def aroundExecuteRequest(pjp: ProceedingJoinPoint, request: WSRequest): Any = {
+ Tracer.currentContext.collect { ctx ⇒
+ val segmentName = PlayExtension.generateHttpClientSegmentName(request)
+ val segment = ctx.startSegment(segmentName, SegmentCategory.HttpClient, PlayExtension.SegmentLibraryName)
+ val response = pjp.proceed().asInstanceOf[Future[WSResponse]]
+
+ response.onComplete(result ⇒ segment.finish())(SameThreadExecutionContext)
+ response
+ } getOrElse pjp.proceed()
+ }
+} \ No newline at end of file
diff --git a/kamon-play-2.5.x/src/test/resources/META-INF/aop.xml b/kamon-play-2.5.x/src/test/resources/META-INF/aop.xml
new file mode 100644
index 00000000..f4c4bc6e
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/resources/META-INF/aop.xml
@@ -0,0 +1,11 @@
+<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
+
+<aspectj>
+ <aspects>
+ <aspect name="kamon.play.instrumentation.FakeRequestIntrumentation"/>
+ </aspects>
+
+ <weaver options="-warn:none">
+ <include within="play.api..*"/>
+ </weaver>
+</aspectj>
diff --git a/kamon-play-2.5.x/src/test/resources/conf/application.conf b/kamon-play-2.5.x/src/test/resources/conf/application.conf
new file mode 100644
index 00000000..28fc1f8a
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/resources/conf/application.conf
@@ -0,0 +1,7 @@
+kamon {
+ play {
+ include-trace-token-header = true
+ trace-token-header-name = "X-Trace-Token"
+ name-generator = kamon.play.TestNameGenerator
+ }
+}
diff --git a/kamon-play-2.5.x/src/test/resources/logback.xml b/kamon-play-2.5.x/src/test/resources/logback.xml
new file mode 100644
index 00000000..c336bbfe
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/resources/logback.xml
@@ -0,0 +1,12 @@
+<configuration>
+ <statusListener class="ch.qos.logback.core.status.NopStatusListener"/>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="OFF">
+ <appender-ref ref="STDOUT"/>
+ </root>
+</configuration> \ No newline at end of file
diff --git a/kamon-play-2.5.x/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala b/kamon-play-2.5.x/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala
new file mode 100644
index 00000000..7a904bdd
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/scala/kamon/play/LoggerLikeInstrumentationSpec.scala
@@ -0,0 +1,122 @@
+/* =========================================================================================
+ * Copyright © 2013-2015 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.play
+
+import ch.qos.logback.classic.spi.ILoggingEvent
+import ch.qos.logback.classic.{ AsyncAppender, LoggerContext }
+import ch.qos.logback.core.read.ListAppender
+import ch.qos.logback.core.status.NopStatusListener
+import kamon.trace.TraceLocal
+import kamon.trace.TraceLocal.AvailableToMdc
+import org.scalatest.BeforeAndAfter
+import org.scalatestplus.play._
+import org.slf4j
+import play.api.LoggerLike
+import play.api.mvc.Results.Ok
+import play.api.mvc._
+import play.api.test.Helpers._
+import play.api.test._
+import scala.concurrent.duration._
+
+import scala.concurrent.{ Await, Future }
+
+class LoggerLikeInstrumentationSpec extends PlaySpec with OneServerPerSuite with BeforeAndAfter {
+ System.setProperty("config.file", "./kamon-play-2.5.x/src/test/resources/conf/application.conf")
+
+ val executor = scala.concurrent.ExecutionContext.Implicits.global
+
+ val infoMessage = "Info Message"
+ val headerValue = "My header value"
+ val otherValue = "My other value"
+
+ val TraceLocalHeaderKey = AvailableToMdc("header")
+ val TraceLocalOtherKey = AvailableToMdc("other")
+
+ before {
+ LoggingHandler.startLogging()
+ }
+
+ after {
+ LoggingHandler.stopLogging()
+ }
+
+ implicit override lazy val app = FakeApplication(withRoutes = {
+
+ case ("GET", "/logging") ⇒
+ Action.async {
+ Future {
+ TraceLocal.store(TraceLocalHeaderKey)(headerValue)
+ TraceLocal.store(TraceLocalOtherKey)(otherValue)
+ LoggingHandler.info(infoMessage)
+ Ok("OK")
+ }(executor)
+ }
+ })
+
+ "the LoggerLike instrumentation" should {
+ "allow retrieve a value from the MDC when was created a key of type AvailableToMdc in the current request" in {
+ LoggingHandler.appenderStart()
+
+ Await.result(route(FakeRequest(GET, "/logging")).get, 10 seconds)
+
+ TraceLocal.retrieve(TraceLocalHeaderKey) must be(Some(headerValue))
+ TraceLocal.retrieve(TraceLocalOtherKey) must be(Some(otherValue))
+
+ LoggingHandler.appenderStop()
+
+ headerValue must be(LoggingHandler.getValueFromMDC("header"))
+ otherValue must be(LoggingHandler.getValueFromMDC("other"))
+ }
+ }
+}
+
+object LoggingHandler extends LoggerLike {
+
+ val loggerContext = new LoggerContext()
+ val rootLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME)
+ val asyncAppender = new AsyncAppender()
+ val listAppender = new ListAppender[ILoggingEvent]()
+ val nopStatusListener = new NopStatusListener()
+
+ override val logger: slf4j.Logger = rootLogger
+
+ def startLogging(): Unit = {
+ loggerContext.getStatusManager().add(nopStatusListener)
+ asyncAppender.setContext(loggerContext)
+ listAppender.setContext(loggerContext)
+ listAppender.setName("list")
+ listAppender.start()
+ }
+
+ def stopLogging(): Unit = {
+ listAppender.stop()
+ }
+
+ def appenderStart(): Unit = {
+ asyncAppender.addAppender(listAppender)
+ asyncAppender.start()
+ rootLogger.addAppender(asyncAppender)
+ }
+
+ def appenderStop(): Unit = {
+ asyncAppender.stop()
+ }
+
+ def getValueFromMDC(key: String): String = {
+ listAppender.list.get(0).getMDCPropertyMap.get(key)
+ }
+}
+
diff --git a/kamon-play-2.5.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play-2.5.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
new file mode 100644
index 00000000..d1429624
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
@@ -0,0 +1,289 @@
+/* =========================================================================================
+ * Copyright © 2013-2015 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.play
+
+import javax.inject.Inject
+
+import kamon.Kamon
+import kamon.metric.instrument.CollectionContext
+import kamon.play.action.TraceName
+import kamon.trace.{ TraceLocal, Tracer }
+import org.scalatestplus.play._
+import play.api.DefaultGlobal
+import play.api.http.{ HttpErrorHandler, HttpFilters, Writeable }
+import play.api.libs.concurrent.Execution.Implicits.defaultContext
+import play.api.libs.ws.{ WSRequest, WS }
+import play.api.mvc.Results.Ok
+import play.api.mvc._
+import play.api.routing.SimpleRouter
+import play.api.test.Helpers._
+import play.api.test._
+import play.core.routing._
+
+import scala.concurrent.duration._
+import scala.concurrent.{ Await, Future }
+import akka.stream.Materializer
+
+class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
+ System.setProperty("config.file", "./kamon-play-2.5.x/src/test/resources/conf/application.conf")
+
+ override lazy val port: Port = 19002
+ val executor = scala.concurrent.ExecutionContext.Implicits.global
+
+ implicit override lazy val app = FakeApplication(withRoutes = {
+ case ("GET", "/async") ⇒
+ Action.async {
+ Future {
+ Ok("Async.async")
+ }(executor)
+ }
+ case ("GET", "/notFound") ⇒
+ Action {
+ Results.NotFound
+ }
+ case ("GET", "/error") ⇒
+ Action {
+ throw new Exception("This page generates an error!")
+ Ok("This page will generate an error!")
+ }
+ case ("GET", "/redirect") ⇒
+ Action {
+ Results.Redirect("/redirected", MOVED_PERMANENTLY)
+ }
+ case ("GET", "/default") ⇒
+ Action {
+ Ok("default")
+ }
+ case ("GET", "/async-renamed") ⇒
+ TraceName("renamed-trace") {
+ Action.async {
+ Future {
+ Ok("Async.async")
+ }(executor)
+ }
+ }
+ case ("GET", "/retrieve") ⇒
+ Action {
+ Ok("retrieve from TraceLocal")
+ }
+ }, additionalConfiguration = Map(
+ ("application.router", "kamon.play.Routes"),
+ ("play.http.filters", "kamon.play.TestHttpFilters"),
+ ("play.http.requestHandler", "play.api.http.DefaultHttpRequestHandler"),
+ ("logger.root", "OFF"),
+ ("logger.play", "OFF"),
+ ("logger.application", "OFF")))
+
+ val traceTokenValue = "kamon-trace-token-test"
+ val traceTokenHeaderName = "X-Trace-Token"
+ val expectedToken = Some(traceTokenValue)
+ val traceTokenHeader = traceTokenHeaderName -> traceTokenValue
+ val traceLocalStorageValue = "localStorageValue"
+ val traceLocalStorageKey = "localStorageKey"
+ val traceLocalStorageHeader = traceLocalStorageKey -> traceLocalStorageValue
+
+ "the Request instrumentation" should {
+ "respond to the Async Action with X-Trace-Token" in {
+ val Some(result) = route(FakeRequest(GET, "/async").withHeaders(traceTokenHeader, traceLocalStorageHeader))
+ header(traceTokenHeaderName, result) must be(expectedToken)
+ }
+
+ "respond to the NotFound Action with X-Trace-Token" in {
+ val Some(result) = route(FakeRequest(GET, "/notFound").withHeaders(traceTokenHeader))
+ header(traceTokenHeaderName, result) must be(expectedToken)
+ }
+
+ "respond to the Default Action with X-Trace-Token" in {
+ val Some(result) = route(FakeRequest(GET, "/default").withHeaders(traceTokenHeader))
+ header(traceTokenHeaderName, result) must be(expectedToken)
+ }
+
+ "respond to the Redirect Action with X-Trace-Token" in {
+ val Some(result) = route(FakeRequest(GET, "/redirect").withHeaders(traceTokenHeader))
+ header("Location", result) must be(Some("/redirected"))
+ header(traceTokenHeaderName, result) must be(expectedToken)
+ }
+
+ "respond to the Async Action with X-Trace-Token and the renamed trace" in {
+ val result = Await.result(route(FakeRequest(GET, "/async-renamed").withHeaders(traceTokenHeader)).get, 10 seconds)
+ Tracer.currentContext.name must be("renamed-trace")
+ Some(result.header.headers(traceTokenHeaderName)) must be(expectedToken)
+ }
+
+ "propagate the TraceContext and LocalStorage through of filters in the current request" in {
+ route(FakeRequest(GET, "/retrieve").withHeaders(traceTokenHeader, traceLocalStorageHeader))
+ TraceLocal.retrieve(TraceLocalKey).get must be(traceLocalStorageValue)
+ }
+
+ "response to the getRouted Action and normalise the current TraceContext name" in {
+ Await.result(WS.url(s"http://localhost:$port/getRouted").get(), 10 seconds)
+ Kamon.metrics.find("getRouted.get", "trace") must not be empty
+ }
+
+ "response to the postRouted Action and normalise the current TraceContext name" in {
+ Await.result(WS.url(s"http://localhost:$port/postRouted").post("content"), 10 seconds)
+ Kamon.metrics.find("postRouted.post", "trace") must not be empty
+ }
+
+ "response to the showRouted Action and normalise the current TraceContext name" in {
+ Await.result(WS.url(s"http://localhost:$port/showRouted/2").get(), 10 seconds)
+ Kamon.metrics.find("show.some.id.get", "trace") must not be empty
+ }
+
+ "record http server metrics for all processed requests" in {
+ val collectionContext = CollectionContext(100)
+ Kamon.metrics.find("play-server", "http-server").get.collect(collectionContext)
+
+ for (repetition ← 1 to 10) {
+ Await.result(route(FakeRequest(GET, "/default").withHeaders(traceTokenHeader)).get, 10 seconds)
+ }
+
+ for (repetition ← 1 to 5) {
+ Await.result(route(FakeRequest(GET, "/notFound").withHeaders(traceTokenHeader)).get, 10 seconds)
+ }
+
+ for (repetition ← 1 to 5) {
+ Await.result(routeWithOnError(FakeRequest(GET, "/error").withHeaders(traceTokenHeader)).get, 10 seconds)
+ }
+
+ val snapshot = Kamon.metrics.find("play-server", "http-server").get.collect(collectionContext)
+ snapshot.counter("GET: /default_200").get.count must be(10)
+ snapshot.counter("GET: /notFound_404").get.count must be(5)
+ snapshot.counter("GET: /error_500").get.count must be(5)
+ snapshot.counter("200").get.count must be(10)
+ snapshot.counter("404").get.count must be(5)
+ snapshot.counter("500").get.count must be(5)
+ }
+ }
+
+ def routeWithOnError[T](req: Request[T])(implicit w: Writeable[T]): Option[Future[Result]] = {
+ route(req).map { result ⇒
+ result.recoverWith {
+ case t: Throwable ⇒ DefaultGlobal.onError(req, t)
+ }
+ }
+ }
+}
+
+object TraceLocalKey extends TraceLocal.TraceLocalKey[String]
+
+class TraceLocalFilter @Inject() (implicit val mat: Materializer) extends Filter {
+
+ val traceLocalStorageValue = "localStorageValue"
+ val traceLocalStorageKey = "localStorageKey"
+ val traceLocalStorageHeader = traceLocalStorageKey -> traceLocalStorageValue
+
+ override def apply(next: (RequestHeader) ⇒ Future[Result])(header: RequestHeader): Future[Result] = {
+ Tracer.withContext(Tracer.currentContext) {
+
+ TraceLocal.store(TraceLocalKey)(header.headers.get(traceLocalStorageKey).getOrElse("unknown"))
+
+ next(header).map {
+ result ⇒
+ {
+ result.withHeaders(traceLocalStorageKey -> TraceLocal.retrieve(TraceLocalKey).get)
+ }
+ }
+ }
+ }
+}
+
+class TestHttpFilters @Inject() (traceLocalFilter: TraceLocalFilter) extends HttpFilters {
+ val filters = Seq(traceLocalFilter)
+}
+
+class Routes @Inject() (application: controllers.Application) extends GeneratedRouter with SimpleRouter {
+ val prefix = "/"
+
+ lazy val defaultPrefix = {
+ if (prefix.endsWith("/")) "" else "/"
+ }
+
+ // Gets
+ private[this] lazy val Application_getRouted =
+ Route("GET", PathPattern(List(StaticPart(prefix), StaticPart(defaultPrefix), StaticPart("getRouted"))))
+
+ private[this] lazy val Application_show =
+ Route("GET", PathPattern(List(StaticPart(prefix), StaticPart(defaultPrefix), StaticPart("showRouted/"), DynamicPart("id", """[^/]+""", encodeable = true))))
+
+ //Posts
+ private[this] lazy val Application_postRouted =
+ Route("POST", PathPattern(List(StaticPart(prefix), StaticPart(defaultPrefix), StaticPart("postRouted"))))
+
+ def routes: PartialFunction[RequestHeader, Handler] = {
+ case Application_getRouted(params) ⇒ call {
+ createInvoker(application.getRouted,
+ HandlerDef(this.getClass.getClassLoader, "", "controllers.Application", "getRouted", Nil, "GET", """some comment""", prefix + """getRouted""")).call(application.getRouted)
+ }
+ case Application_postRouted(params) ⇒ call {
+ createInvoker(application.postRouted,
+ HandlerDef(this.getClass.getClassLoader, "", "controllers.Application", "postRouted", Nil, "POST", """some comment""", prefix + """postRouted""")).call(application.postRouted)
+ }
+ case Application_show(params) ⇒ call(params.fromPath[Int]("id", None)) { (id) ⇒
+ createInvoker(application.showRouted(id),
+ HandlerDef(this.getClass.getClassLoader, "", "controllers.Application", "showRouted", Seq(classOf[Int]), "GET", """""", prefix + """show/some/$id<[^/]+>""")).call(application.showRouted(id))
+ }
+ }
+
+ override def errorHandler: HttpErrorHandler = new HttpErrorHandler() {
+ override def onClientError(request: RequestHeader, statusCode: Int, message: String): Future[Result] = Future.successful(Results.InternalServerError)
+ override def onServerError(request: RequestHeader, exception: Throwable): Future[Result] = Future.successful(Results.InternalServerError)
+ }
+}
+
+object controllers {
+ import play.api.mvc._
+
+ class Application extends Controller {
+ val postRouted = Action {
+ Ok("invoked postRouted")
+ }
+ val getRouted = Action {
+ Ok("invoked getRouted")
+ }
+ def showRouted(id: Int) = Action {
+ Ok("invoked show with: " + id)
+ }
+ }
+}
+
+class TestNameGenerator extends NameGenerator {
+ import scala.collection.concurrent.TrieMap
+ import play.api.routing.Router
+ import java.util.Locale
+ import kamon.util.TriemapAtomicGetOrElseUpdate.Syntax
+
+ private val cache = TrieMap.empty[String, String]
+ private val normalizePattern = """\$([^<]+)<[^>]+>""".r
+
+ def generateTraceName(requestHeader: RequestHeader): String = requestHeader.tags.get(Router.Tags.RouteVerb).map { verb ⇒
+ val path = requestHeader.tags(Router.Tags.RoutePattern)
+ cache.atomicGetOrElseUpdate(s"$verb$path", {
+ val traceName = {
+ // Convert paths of form GET /foo/bar/$paramname<regexp>/blah to foo.bar.paramname.blah.get
+ val p = normalizePattern.replaceAllIn(path, "$1").replace('/', '.').dropWhile(_ == '.')
+ val normalisedPath = {
+ if (p.lastOption.exists(_ != '.')) s"$p."
+ else p
+ }
+ s"$normalisedPath${verb.toLowerCase(Locale.ENGLISH)}"
+ }
+ traceName
+ })
+ } getOrElse s"${requestHeader.method}: ${requestHeader.uri}"
+
+ def generateHttpClientSegmentName(request: WSRequest): String = request.url
+} \ No newline at end of file
diff --git a/kamon-play-2.5.x/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play-2.5.x/src/test/scala/kamon/play/WSInstrumentationSpec.scala
new file mode 100644
index 00000000..f06fc9ea
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/scala/kamon/play/WSInstrumentationSpec.scala
@@ -0,0 +1,96 @@
+/* ===================================================
+ * Copyright © 2013-2015 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.play
+
+import kamon.Kamon
+import kamon.metric.{ Entity, EntitySnapshot, TraceMetrics }
+import kamon.trace.{ Tracer, TraceContext, SegmentCategory }
+import org.scalatest.{ Matchers, WordSpecLike }
+import org.scalatestplus.play.OneServerPerSuite
+import play.api.libs.ws.WS
+import play.api.mvc.Action
+import play.api.mvc.Results.Ok
+import play.api.test.Helpers._
+import play.api.test._
+
+import scala.concurrent.Await
+import scala.concurrent.duration._
+
+class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPerSuite {
+ System.setProperty("config.file", "./kamon-play-2.5.x/src/test/resources/conf/application.conf")
+
+ override lazy val port: Port = 19003
+ implicit override lazy val app = FakeApplication(withRoutes = {
+ case ("GET", "/async") ⇒ Action { Ok("ok") }
+ case ("GET", "/outside") ⇒ Action { Ok("ok") }
+ case ("GET", "/inside") ⇒ callWSinsideController(s"http://localhost:$port/async")
+ })
+
+ "the WS instrumentation" should {
+ "propagate the TraceContext inside an Action and complete the WS request" in {
+ Await.result(route(FakeRequest(GET, "/inside")).get, 10 seconds)
+
+ val snapshot = takeSnapshotOf("GET: /inside", "trace")
+ snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1)
+
+ val segmentMetricsSnapshot = takeSnapshotOf(s"http://localhost:$port/async", "trace-segment",
+ tags = Map(
+ "trace" -> "GET: /inside",
+ "category" -> SegmentCategory.HttpClient,
+ "library" -> PlayExtension.SegmentLibraryName))
+
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1)
+ }
+
+ "propagate the TraceContext outside an Action and complete the WS request" in {
+ Tracer.withContext(newContext("trace-outside-action")) {
+ Await.result(WS.url(s"http://localhost:$port/outside").get(), 10 seconds)
+ Tracer.currentContext.finish()
+ }
+
+ val snapshot = takeSnapshotOf("trace-outside-action", "trace")
+ snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1)
+
+ val segmentMetricsSnapshot = takeSnapshotOf(s"http://localhost:$port/outside", "trace-segment",
+ tags = Map(
+ "trace" -> "trace-outside-action",
+ "category" -> SegmentCategory.HttpClient,
+ "library" -> PlayExtension.SegmentLibraryName))
+
+ segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1)
+ }
+ }
+
+ lazy val collectionContext = Kamon.metrics.buildDefaultCollectionContext
+
+ def newContext(name: String): TraceContext =
+ Kamon.tracer.newContext(name)
+
+ def takeSnapshotOf(name: String, category: String, tags: Map[String, String] = Map.empty): EntitySnapshot = {
+ val recorder = Kamon.metrics.find(Entity(name, category, tags)).get
+ recorder.collect(collectionContext)
+ }
+
+ def callWSinsideController(url: String) = Action.async {
+ import play.api.Play.current
+ import play.api.libs.concurrent.Execution.Implicits.defaultContext
+
+ WS.url(url).get().map { response ⇒
+ Ok("Ok")
+ }
+ }
+}
diff --git a/kamon-play-2.5.x/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala b/kamon-play-2.5.x/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala
new file mode 100644
index 00000000..10e285db
--- /dev/null
+++ b/kamon-play-2.5.x/src/test/scala/kamon/play/instrumentation/FakeRequestIntrumentation.scala
@@ -0,0 +1,27 @@
+/* ===================================================
+ * 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.play.instrumentation
+
+import org.aspectj.lang.annotation.{ DeclareMixin, Aspect }
+import kamon.trace.TraceContextAware
+
+@Aspect
+class FakeRequestIntrumentation {
+
+ @DeclareMixin("play.api.test.FakeRequest")
+ def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default
+}
diff --git a/project/Dependencies.scala b/project/Dependencies.scala
index 28c9e237..f490800b 100644
--- a/project/Dependencies.scala
+++ b/project/Dependencies.scala
@@ -29,6 +29,7 @@ object Dependencies {
val slf4jVersion = "1.7.7"
val play23Version = "2.3.10"
val play24Version = "2.4.6"
+ val play25Version = "2.5.4"
val elasticsearchVersion = "2.1.0"
val sprayJson = "io.spray" %% "spray-json" % "1.3.1"
@@ -70,6 +71,11 @@ object Dependencies {
val playTest24 = "org.scalatestplus" %% "play" % "1.4.0-M2"
val typesafeConfig = "com.typesafe" % "config" % "1.2.1"
+ //play 2.5.x
+ val play25 = "com.typesafe.play" %% "play" % play25Version
+ val playWS25 = "com.typesafe.play" %% "play-ws" % play25Version
+ val playTest25 = "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.0"
+
val elasticsearch = "org.elasticsearch" % "elasticsearch" % elasticsearchVersion
def compile (deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile")
diff --git a/project/Projects.scala b/project/Projects.scala
index 10876485..15fd5090 100644
--- a/project/Projects.scala
+++ b/project/Projects.scala
@@ -15,6 +15,7 @@
import sbt._
import Keys._
+import sbtdoge._
object Projects extends Build {
import AspectJ._
@@ -22,9 +23,10 @@ object Projects extends Build {
import Dependencies._
lazy val kamon = Project("kamon", file("."))
+ .enablePlugins(CrossPerProjectPlugin)
.aggregate(kamonCore, kamonScala, kamonAkka, kamonSpray, kamonNewrelic, kamonPlayground, kamonTestkit,
kamonStatsD, kamonRiemann, kamonDatadog, kamonSPM, kamonSystemMetrics, kamonLogReporter, kamonAkkaRemote, kamonJdbc,
- kamonAnnotation, kamonPlay23, kamonPlay24, kamonJMXReporter, kamonFluentd, kamonAutoweave, kamonInfluxDB)
+ kamonAnnotation, kamonPlay23, kamonPlay24, kamonPlay25, kamonJMXReporter, kamonFluentd, kamonAutoweave, kamonInfluxDB)
.settings(basicSettings: _*)
.settings(formatSettings: _*)
.settings(noPublishing: _*)
@@ -148,6 +150,18 @@ object Projects extends Build {
provided(aspectJ, typesafeConfig) ++
test(playTest24, akkaTestKit, slf4jApi))
+ lazy val kamonPlay25 = Project("kamon-play-25", file("kamon-play-2.5.x"))
+ .dependsOn(kamonCore % "compile->compile;test->test", kamonScala)
+ .settings(basicSettings: _*)
+ .settings(formatSettings: _*)
+ .settings(aspectJSettings: _*)
+ .settings(
+ crossScalaVersions := Seq(ScalaVersion),
+ libraryDependencies ++=
+ compile(play25, playWS25) ++
+ provided(aspectJ, typesafeConfig) ++
+ test(playTest25, akkaTestKit, slf4jApi))
+
lazy val kamonInfluxDB = Project("kamon-influxdb", file("kamon-influxdb"))
.dependsOn(kamonCore % "compile->compile;test->test")
.settings(basicSettings: _*)
diff --git a/project/Settings.scala b/project/Settings.scala
index 1b71710e..edb1ce54 100644
--- a/project/Settings.scala
+++ b/project/Settings.scala
@@ -29,7 +29,8 @@ object Settings {
lazy val basicSettings = Seq(
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
- crossScalaVersions := Seq("2.10.5", "2.11.6"),
+ scalaVersion := ScalaVersion,
+ crossScalaVersions := Seq("2.10.5", ScalaVersion),
resolvers ++= Dependencies.resolutionRepos,
fork in run := true,
parallelExecution in Global := false,
diff --git a/project/plugins.sbt b/project/plugins.sbt
index ab52e642..46e23b89 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -15,3 +15,5 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.1")
+
+addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5")