diff options
Diffstat (limited to 'kamon-play-2.3.x')
3 files changed, 4 insertions, 36 deletions
diff --git a/kamon-play-2.3.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala b/kamon-play-2.3.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala index 7dcb7913..c8a808ec 100644 --- a/kamon-play-2.3.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala +++ b/kamon-play-2.3.x/src/main/scala/kamon/play/instrumentation/RequestInstrumentation.scala @@ -17,7 +17,6 @@ package kamon.play.instrumentation import kamon.Kamon import kamon.play.Play -import kamon.trace.TraceLocal.{ HttpContext, HttpContextKey } import kamon.trace._ import kamon.util.SameThreadExecutionContext import org.aspectj.lang.ProceedingJoinPoint @@ -28,8 +27,6 @@ import play.api.mvc._ @Aspect class RequestInstrumentation { - import RequestInstrumentation._ - @DeclareMixin("play.api.mvc.RequestHeader+") def mixinContextAwareNewRequest: TraceContextAware = TraceContextAware.default @@ -63,16 +60,11 @@ class RequestInstrumentation { } getOrElse result } - //store in TraceLocal useful data to diagnose errors - storeDiagnosticData(requestHeader) - //override the current trace name Tracer.currentContext.rename(playExtension.generateTraceName(requestHeader)) - // Invoke the action next(requestHeader).map(onResult)(SameThreadExecutionContext) } - pjp.proceed(Array(EssentialAction(essentialAction))) } @@ -85,17 +77,4 @@ class RequestInstrumentation { def recordHttpServerMetrics(header: ResponseHeader, traceName: String): Unit = Kamon(Play).httpServerMetrics.recordResponse(traceName, header.status.toString) - - def storeDiagnosticData(request: RequestHeader): Unit = { - val agent = request.headers.get(UserAgent).getOrElse(Unknown) - val forwarded = request.headers.get(XForwardedFor).getOrElse(Unknown) - - TraceLocal.store(HttpContextKey)(HttpContext(agent, request.uri, forwarded)) - } -} - -object RequestInstrumentation { - val UserAgent = "User-Agent" - val XForwardedFor = "X-Forwarded-For" - val Unknown = "unknown" } diff --git a/kamon-play-2.3.x/src/test/resources/META-INF/aop.xml b/kamon-play-2.3.x/src/test/resources/META-INF/aop.xml index 2888a31a..dd2481aa 100644 --- a/kamon-play-2.3.x/src/test/resources/META-INF/aop.xml +++ b/kamon-play-2.3.x/src/test/resources/META-INF/aop.xml @@ -5,7 +5,7 @@ <aspect name="kamon.play.instrumentation.FakeRequestIntrumentation"/> </aspects> - <weaver> - <include within="play.api..*"/> - </weaver> + <weaver options="-warn:none"> + <include within="play.api..*"/> + </weaver> </aspectj> diff --git a/kamon-play-2.3.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play-2.3.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala index 2796cfa5..7efb05d9 100644 --- a/kamon-play-2.3.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala +++ b/kamon-play-2.3.x/src/test/scala/kamon/play/RequestInstrumentationSpec.scala @@ -18,7 +18,6 @@ package kamon.play import kamon.Kamon import kamon.metric.instrument.CollectionContext import kamon.play.action.TraceName -import kamon.trace.TraceLocal.HttpContextKey import kamon.trace.{ Tracer, TraceLocal } import org.scalatestplus.play._ import play.api.DefaultGlobal @@ -40,7 +39,7 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite { Kamon.start() - override lazy val port: Port = 19002 + override lazy val port: Port = 19001 val executor = scala.concurrent.ExecutionContext.Implicits.global implicit override lazy val app = FakeApplication(withGlobal = Some(MockGlobalTest), withRoutes = { @@ -142,16 +141,6 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite { Kamon.metrics.find("show.some.id.get", "trace") must not be empty } - "include HttpContext information for help to diagnose possible errors" in { - Await.result(WS.url(s"http://localhost:$port/getRouted").get(), 10 seconds) - route(FakeRequest(GET, "/default").withHeaders("User-Agent" -> "Fake-Agent")) - - val httpCtx = TraceLocal.retrieve(HttpContextKey).get - httpCtx.agent must be("Fake-Agent") - httpCtx.uri must be("/default") - httpCtx.xforwarded must be("unknown") - } - "record http server metrics for all processed requests" in { val collectionContext = CollectionContext(100) Kamon.metrics.find("play-server", "http-server").get.collect(collectionContext) |