aboutsummaryrefslogtreecommitdiff
path: root/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2014-09-09 22:23:03 -0300
committerDiego <diegolparra@gmail.com>2014-09-09 22:23:03 -0300
commite3ce632beb18f4c1f69eff246ff5c646fd315c46 (patch)
tree190a2a2021b22b020ac327b8230cf1dc4295466a /kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
parent6884c0f3f7bf9376e9eaf4f330d7622c142399e3 (diff)
downloadKamon-e3ce632beb18f4c1f69eff246ff5c646fd315c46.tar.gz
Kamon-e3ce632beb18f4c1f69eff246ff5c646fd315c46.tar.bz2
Kamon-e3ce632beb18f4c1f69eff246ff5c646fd315c46.zip
= play: * fix tests
* use kamon default dispatcher
Diffstat (limited to 'kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala')
-rw-r--r--kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala24
1 files changed, 14 insertions, 10 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
index cbd95db3..3378d477 100644
--- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
+++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala
@@ -19,6 +19,7 @@ package kamon.play
import kamon.Kamon
import kamon.metric.TraceMetrics.{ HttpClientRequest, TraceMetricsSnapshot }
import kamon.metric.{ Metrics, TraceMetrics }
+import kamon.trace.TraceRecorder
import org.scalatest.{ Matchers, WordSpecLike }
import org.scalatestplus.play.OneServerPerSuite
import play.api.libs.ws.WS
@@ -42,22 +43,25 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer
})
"the WS instrumentation" should {
- "propagate the TraceContext outside an Action and complete the WS request" in {
- Await.result(WS.url("http://localhost:19001/outside").get(), 10 seconds)
+ "propagate the TraceContext inside an Action and complete the WS request" in {
+ Await.result(route(FakeRequest(GET, "/inside")).get, 10 seconds)
- val snapshot = takeSnapshotOf("http://localhost:19001/outside")
+ val snapshot = takeSnapshotOf("GET: /inside")
snapshot.elapsedTime.numberOfMeasurements should be(1)
snapshot.segments.size should be(1)
- snapshot.segments(HttpClientRequest("http://localhost:19001/outside")).numberOfMeasurements should be(1)
+ snapshot.segments(HttpClientRequest("http://localhost:19001/async")).numberOfMeasurements should be(1)
}
- "propagate the TraceContext inside an Action and complete the WS request" in {
- Await.result(route(FakeRequest(GET, "/inside")).get, 10 seconds)
+ "propagate the TraceContext outside an Action and complete the WS request" in {
+ TraceRecorder.withNewTraceContext("trace-outside-action") {
+ Await.result(WS.url("http://localhost:19001/outside").get(), 10 seconds)
+ TraceRecorder.finish()
+ }(Akka.system())
- val snapshot = takeSnapshotOf("GET: /inside")
- snapshot.elapsedTime.numberOfMeasurements should be(2)
+ val snapshot = takeSnapshotOf("trace-outside-action")
+ snapshot.elapsedTime.numberOfMeasurements should be(1)
snapshot.segments.size should be(1)
- snapshot.segments(HttpClientRequest("http://localhost:19001/async")).numberOfMeasurements should be(1)
+ snapshot.segments(HttpClientRequest("http://localhost:19001/outside")).numberOfMeasurements should be(1)
}
}
@@ -69,8 +73,8 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer
}
def callWSinsideController(url: String) = Action.async {
- import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.Play.current
+ import play.api.libs.concurrent.Execution.Implicits.defaultContext
WS.url(url).get().map { response ⇒
Ok("Ok")