diff options
Diffstat (limited to 'kamon-play/src')
4 files changed, 9 insertions, 10 deletions
diff --git a/kamon-play/src/main/scala/kamon/play/Play.scala b/kamon-play/src/main/scala/kamon/play/Play.scala index 9b69f9a3..6c6cbf4c 100644 --- a/kamon-play/src/main/scala/kamon/play/Play.scala +++ b/kamon-play/src/main/scala/kamon/play/Play.scala @@ -55,6 +55,6 @@ trait PlayNameGenerator { } class DefaultPlayNameGenerator extends PlayNameGenerator { - def generateTraceName(requestHeader: RequestHeader): String = requestHeader.method + ": " + requestHeader.uri + def generateTraceName(requestHeader: RequestHeader): String = s"${requestHeader.method}: ${requestHeader.uri}" def generateHttpClientSegmentName(request: WSRequest): String = request.url } diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala index 1ce41a75..1bafa8ff 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -55,7 +55,7 @@ class RequestInstrumentation { @Around("call(* play.api.GlobalSettings.doFilter(*)) && args(next)") def aroundDoFilter(pjp: ProceedingJoinPoint, next: EssentialAction): Any = { val essentialAction = (requestHeader: RequestHeader) ⇒ { - // TODO: Move to a Kamon-specific dispatcher. + val executor = Kamon(Play)(Akka.system()).defaultDispatcher def onResult(result: Result): Result = { diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala index f16c76c8..fca13c4c 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala @@ -18,7 +18,7 @@ package kamon.play.instrumentation import kamon.Kamon import kamon.play.Play -import kamon.trace.{ SegmentCategory, SegmentMetricIdentity, TraceRecorder } +import kamon.trace.{ SegmentCategory, TraceRecorder } import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } import play.api.libs.ws.{ WSRequest, WSResponse } @@ -42,6 +42,6 @@ class WSInstrumentation { response.map(result ⇒ segment.finish())(executor) response - } getOrElse (pjp.proceed()) + } getOrElse pjp.proceed() } }
\ No newline at end of file diff --git a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala index 3c3ce9f2..564d5abe 100644 --- a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala +++ b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala @@ -21,7 +21,6 @@ import kamon.metric.{ CollectionContext, Metrics, TraceMetrics } import kamon.play.action.TraceName import kamon.trace.TraceLocal.HttpContextKey import kamon.trace.{ TraceLocal, TraceRecorder } -import org.scalatest.Matchers import org.scalatestplus.play._ import play.api.DefaultGlobal import play.api.http.Writeable @@ -124,23 +123,23 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite { } "propagate the TraceContext and LocalStorage through of filters in the current request" in { - val Some(result) = route(FakeRequest(GET, "/retrieve").withHeaders(traceTokenHeader, traceLocalStorageHeader)) + 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("http://localhost:19001/getRouted").get(), 10 seconds) - Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("getRouted.get")) must not be (empty) + Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("getRouted.get")) must not be empty } "response to the postRouted Action and normalise the current TraceContext name" in { Await.result(WS.url("http://localhost:19001/postRouted").post("content"), 10 seconds) - Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("postRouted.post")) must not be (empty) + Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("postRouted.post")) must not be empty } "response to the showRouted Action and normalise the current TraceContext name" in { Await.result(WS.url("http://localhost:19001/showRouted/2").get(), 10 seconds) - Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("show.some.id.get")) must not be (empty) + Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("show.some.id.get")) must not be empty } "include HttpContext information for help to diagnose possible errors" in { @@ -230,7 +229,7 @@ object Routes extends Router.Routes { Route("GET", PathPattern(List(StaticPart(Routes.prefix), StaticPart(Routes.defaultPrefix), StaticPart("getRouted")))) private[this] lazy val Application_show = - Route("GET", PathPattern(List(StaticPart(Routes.prefix), StaticPart(Routes.defaultPrefix), StaticPart("showRouted/"), DynamicPart("id", """[^/]+""", true)))) + Route("GET", PathPattern(List(StaticPart(Routes.prefix), StaticPart(Routes.defaultPrefix), StaticPart("showRouted/"), DynamicPart("id", """[^/]+""", encodeable = true)))) //Posts private[this] lazy val Application_postRouted = |