blob: 61e651c259c0ad0ec2f9d2749eaa25e8d8487e98 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()
}
}
|