aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala')
-rw-r--r--kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala41
1 files changed, 41 insertions, 0 deletions
diff --git a/kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala b/kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala
new file mode 100644
index 00000000..61e651c2
--- /dev/null
+++ b/kamon-core/src/test/scala/kamon/trace/RealSpanSpec.scala
@@ -0,0 +1,41 @@
+package kamon.trace
+
+import kamon.testkit.{Reconfigure, TestSpanReporter}
+import kamon.util.Registration
+import kamon.Kamon
+import org.scalatest.concurrent.Eventually
+import org.scalatest.{BeforeAndAfterAll, Matchers, OptionValues, WordSpec}
+import org.scalatest.time.SpanSugar._
+
+class RealSpanSpec extends WordSpec with Matchers with BeforeAndAfterAll with Eventually with OptionValues with Reconfigure {
+
+ "a real span" when {
+ "sampled" should {
+ "be sent to the Span reporters" in {
+
+ Kamon.buildSpan("test-span")
+ .withSpanTag("test", "value")
+ .start()
+ .finish()
+
+ eventually(timeout(50 milliseconds)) {
+ val finishedSpan = reporter.nextSpan().value
+ finishedSpan.operationName shouldBe("test-span")
+ }
+ }
+ }
+ }
+
+ @volatile var registration: Registration = _
+ val reporter = new TestSpanReporter()
+
+ override protected def beforeAll(): Unit = {
+ enableFastSpanFlushing()
+ sampleAlways()
+ registration = Kamon.addReporter(reporter)
+ }
+
+ override protected def afterAll(): Unit = {
+ registration.cancel()
+ }
+}