aboutsummaryrefslogtreecommitdiff
path: root/kamon-play/src/test
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2014-11-30 17:24:37 -0300
committerDiego <diegolparra@gmail.com>2014-11-30 17:24:37 -0300
commit433bd42c21c04a8c9af2400eadabd82e6a524c12 (patch)
tree58e7bba6507d6935283e68e8eaebc42e296b93a8 /kamon-play/src/test
parentd87efc71d82220a4d6f5dba50a7424a5360ea63b (diff)
downloadKamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.tar.gz
Kamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.tar.bz2
Kamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.zip
+ play, spray, newrelic: store in TraceLocal useful data to diagnose errors and closes #6
Diffstat (limited to 'kamon-play/src/test')
-rw-r--r--kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala21
1 files changed, 18 insertions, 3 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
index 3feb6246..3c3ce9f2 100644
--- a/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/RequestInstrumentationSpec.scala
@@ -19,7 +19,9 @@ import kamon.Kamon
import kamon.http.HttpServerMetrics
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
@@ -127,7 +129,7 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
}
"response to the getRouted Action and normalise the current TraceContext name" in {
- Await.result(WS.url("http://localhost:19001/getRouted").get, 10 seconds)
+ Await.result(WS.url("http://localhost:19001/getRouted").get(), 10 seconds)
Kamon(Metrics)(Akka.system()).storage.get(TraceMetrics("getRouted.get")) must not be (empty)
}
@@ -137,10 +139,20 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
}
"response to the showRouted Action and normalise the current TraceContext name" in {
- Await.result(WS.url("http://localhost:19001/showRouted/2").get, 10 seconds)
+ 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)
}
+ "include HttpContext information for help to diagnose possible errors" in {
+ Await.result(WS.url("http://localhost:19001/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)(Akka.system()).register(HttpServerMetrics, HttpServerMetrics.Factory).get.collect(collectionContext)
@@ -180,7 +192,10 @@ class RequestInstrumentationSpec extends PlaySpec with OneServerPerSuite {
TraceLocal.store(TraceLocalKey)(header.headers.get(traceLocalStorageKey).getOrElse("unknown"))
next(header).map {
- result ⇒ result.withHeaders((traceLocalStorageKey -> TraceLocal.retrieve(TraceLocalKey).get))
+ result ⇒
+ {
+ result.withHeaders(traceLocalStorageKey -> TraceLocal.retrieve(TraceLocalKey).get)
+ }
}
}
}