Skip to content

Commit 3c261d8

Browse files
authored
Merge pull request #978 from duxet/w3c-spanid-fix
Fix invalid SpanID issue with W3C propagation
2 parents 7339c32 + fb18965 commit 3c261d8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

core/kamon-core-tests/src/test/scala/kamon/trace/W3CTraceContextSpanPropagationSpec.scala

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class W3CTraceContextSpanPropagationSpec extends WordSpecLike with Matchers with
3131
)
3232

3333
val spanContext = traceContextPropagation.read(headerReaderFromMap(headersMap), Context.Empty).get(Span.Key)
34-
spanContext.id.string shouldBe "00000000000000000000000001020304"
3534
spanContext.parentId.string shouldBe "0000000004030201"
3635
spanContext.trace.id.string shouldBe "00000000000000000000000001020304"
3736
spanContext.trace.samplingDecision shouldBe SamplingDecision.Sample

core/kamon-core/src/main/scala/kamon/trace/SpanPropagation.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ object W3CTraceContext {
9090
val traceParentComponents = traceParent.split("-")
9191

9292
if (traceParentComponents.length != 4) None else {
93+
val spanID = identityProvider.spanIdFactory.generate()
9394
val traceID = identityProvider.traceIdFactory.from(traceParentComponents(1))
94-
val spanID = identityProvider.spanIdFactory.from(traceParentComponents(2))
95+
val parentSpanID = identityProvider.spanIdFactory.from(traceParentComponents(2))
9596
val samplingDecision = unpackSamplingDecision(traceParentComponents(3))
9697

97-
Some(Span.Remote(traceID, spanID, Trace(traceID, samplingDecision)))
98+
Some(Span.Remote(spanID, parentSpanID, Trace(traceID, samplingDecision)))
9899
}
99100
}
100101

0 commit comments

Comments
 (0)