diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-14 10:22:58 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-14 10:22:58 +0100 |
commit | 7da906da4fda6c6cd7eb6384bff0aef6b4ba094f (patch) | |
tree | c592468abcc6c482e3836987b8e9005957a88bbe /kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala | |
parent | c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8 (diff) | |
download | Kamon-7da906da4fda6c6cd7eb6384bff0aef6b4ba094f.tar.gz Kamon-7da906da4fda6c6cd7eb6384bff0aef6b4ba094f.tar.bz2 Kamon-7da906da4fda6c6cd7eb6384bff0aef6b4ba094f.zip |
= play: ensure that tests use different ports.
Diffstat (limited to 'kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala')
-rw-r--r-- | kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala index 9e87da84..577d9bed 100644 --- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala +++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala @@ -35,10 +35,11 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer import kamon.metric.TraceMetricsSpec.SegmentSyntax System.setProperty("config.file", "./kamon-play/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("http://localhost:19001/async") + case ("GET", "/inside") ⇒ callWSinsideController(s"http://localhost:$port/async") }) "the WS instrumentation" should { @@ -48,19 +49,19 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer val snapshot = takeSnapshotOf("GET: /inside") snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) snapshot.segments.size should be(1) - snapshot.segment("http://localhost:19001/async", SegmentCategory.HttpClient, Play.SegmentLibraryName).numberOfMeasurements should be(1) + snapshot.segment(s"http://localhost:$port/async", SegmentCategory.HttpClient, Play.SegmentLibraryName).numberOfMeasurements should be(1) } "propagate the TraceContext outside an Action and complete the WS request" in { TraceContext.withContext(newContext("trace-outside-action")) { - Await.result(WS.url("http://localhost:19001/outside").get(), 10 seconds) + Await.result(WS.url(s"http://localhost:$port/outside").get(), 10 seconds) TraceContext.currentContext.finish() } val snapshot = takeSnapshotOf("trace-outside-action") snapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) snapshot.segments.size should be(1) - snapshot.segment("http://localhost:19001/outside", SegmentCategory.HttpClient, Play.SegmentLibraryName).numberOfMeasurements should be(1) + snapshot.segment(s"http://localhost:$port/outside", SegmentCategory.HttpClient, Play.SegmentLibraryName).numberOfMeasurements should be(1) } } @@ -69,6 +70,8 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer Kamon.tracer.newContext(name) def takeSnapshotOf(traceName: String): EntitySnapshot = { + // Give some time for async segments to finish. + Thread.sleep(300) val recorder = Kamon.metrics.register(TraceMetrics, traceName).get.recorder val collectionContext = Kamon.metrics.buildDefaultCollectionContext recorder.collect(collectionContext) |