Skip to content

Commit

Permalink
Encode SpanID and ParentSpanID as a 16 hex characters in zipkin propa…
Browse files Browse the repository at this point in the history
…gator

Based on the openzipkin/b3-propagation specification, the SpanID and
ParentSpanID are to be encoded as 16 lower-hex characters.

jaegertracing#533 fixed this
for TraceID, and fixed the SpanID.String() method, but did not update
the Zipkin Propagator SpanID encoding.

This fix uses SpanID.String() to ensure proper encoding of the SpanID and
ParentSpandID within the Zipkin Propagator.

Signed-off-by: Nathan Bowler <nzb301@psu.edu>
  • Loading branch information
nabowler committed Oct 6, 2021
1 parent 7aa7af5 commit d917c92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions zipkin/propagation.go
Expand Up @@ -61,9 +61,9 @@ func (p Propagator) Inject(

textMapWriter.Set("x-b3-traceid", sc.TraceID().String())
if sc.ParentID() != 0 {
textMapWriter.Set("x-b3-parentspanid", strconv.FormatUint(uint64(sc.ParentID()), 16))
textMapWriter.Set("x-b3-parentspanid", sc.ParentID().String())
}
textMapWriter.Set("x-b3-spanid", strconv.FormatUint(uint64(sc.SpanID()), 16))
textMapWriter.Set("x-b3-spanid", sc.SpanID().String())
if sc.IsSampled() {
textMapWriter.Set("x-b3-sampled", "1")
} else {
Expand Down
20 changes: 10 additions & 10 deletions zipkin/propagation_test.go
Expand Up @@ -33,31 +33,31 @@ var (
var (
rootSampledHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-sampled": "1",
"baggage-foo": "bar",
}
nonRootSampledHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-parentspanid": "1",
"x-b3-spanid": "0000000000000002",
"x-b3-parentspanid": "0000000000000001",
"x-b3-sampled": "1",
}
nonRootNonSampledHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-parentspanid": "1",
"x-b3-spanid": "0000000000000002",
"x-b3-parentspanid": "0000000000000001",
"x-b3-sampled": "0",
}
rootSampledBooleanHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-sampled": "true",
"baggage-foo": "bar",
}
nonRootSampledBooleanHeader = opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-parentspanid": "1",
"x-b3-sampled": "true",
}
Expand All @@ -69,12 +69,12 @@ var (
}
sampled128bitTraceID = opentracing.TextMapCarrier{
"x-b3-traceid": "463ac35c9f6413ad48485a3953bb6124",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-sampled": "1",
}
invalidTraceID = opentracing.TextMapCarrier{
"x-b3-traceid": "00000000000000000000000000000000",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-sampled": "1",
}
)
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestCustomBaggagePrefix(t *testing.T) {
assert.Nil(t, err)
m := opentracing.TextMapCarrier{
"x-b3-traceid": "0000000000000001",
"x-b3-spanid": "2",
"x-b3-spanid": "0000000000000002",
"x-b3-sampled": "1",
"emoji:)foo": "bar",
}
Expand Down

0 comments on commit d917c92

Please sign in to comment.