aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala')
-rw-r--r--kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala22
1 files changed, 19 insertions, 3 deletions
diff --git a/kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala b/kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala
index e6fa283e..f718d806 100644
--- a/kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala
+++ b/kamon-core-tests/src/test/scala/kamon/trace/B3SpanCodecSpec.scala
@@ -28,15 +28,21 @@ class B3SpanCodecSpec extends WordSpecLike with Matchers with OptionValues with
"The ExtendedB3 SpanContextCodec" should {
"return a TextMap containing the SpanContext data" in {
- val context = testContext()
-
- val textMap = extendedB3Codec.encode(context)
+ val textMap = extendedB3Codec.encode(testContext())
textMap.get("X-B3-TraceId").value shouldBe "1234"
textMap.get("X-B3-ParentSpanId").value shouldBe "2222"
textMap.get("X-B3-SpanId").value shouldBe "4321"
textMap.get("X-B3-Sampled").value shouldBe "1"
}
+ "do not include the X-B3-ParentSpanId if there is no parent" in {
+ val textMap = extendedB3Codec.encode(testContextWithoutParent())
+ textMap.get("X-B3-TraceId").value shouldBe "1234"
+ textMap.get("X-B3-ParentSpanId") shouldBe empty
+ textMap.get("X-B3-SpanId").value shouldBe "4321"
+ textMap.get("X-B3-Sampled").value shouldBe "1"
+ }
+
"not inject anything if there is no Span in the Context" in {
val textMap = extendedB3Codec.encode(Context.Empty)
@@ -189,4 +195,14 @@ class B3SpanCodecSpec extends WordSpecLike with Matchers with OptionValues with
Context.create().withKey(Span.ContextKey, Span.Remote(spanContext))
}
+ def testContextWithoutParent(): Context = {
+ val spanContext = createSpanContext().copy(
+ traceID = Identifier("1234", Array[Byte](1, 2, 3, 4)),
+ spanID = Identifier("4321", Array[Byte](4, 3, 2, 1)),
+ parentID = IdentityProvider.NoIdentifier
+ )
+
+ Context.create().withKey(Span.ContextKey, Span.Remote(spanContext))
+ }
+
} \ No newline at end of file