diff --git a/ddtrace/tracer/textmap.go b/ddtrace/tracer/textmap.go index cd9b7860f8..1fee0ba689 100644 --- a/ddtrace/tracer/textmap.go +++ b/ddtrace/tracer/textmap.go @@ -507,7 +507,7 @@ func getDatadogPropagator(cp *chainedPropagator) *propagator { // if the reparenting ID is not set on the context, the span ID from datadog headers is used. func overrideDatadogParentID(ctx, w3cCtx, ddCtx *spanContext) { ctx.spanID = w3cCtx.spanID - if w3cCtx.reparentID != "" && w3cCtx.reparentID != "0000000000000000" { + if w3cCtx.reparentID != "" { ctx.reparentID = w3cCtx.reparentID } else if ddCtx != nil { // NIT: could be done without using fmt.Sprintf? Is it worth it? @@ -967,7 +967,7 @@ func composeTracestate(ctx *spanContext, priority int, oldState string) string { if !ctx.isRemote { b.WriteString(";p:") b.WriteString(spanIDHexEncoded(ctx.SpanID(), 16)) - } else if ctx.reparentID != "" && ctx.reparentID != "0000000000000000" { + } else if ctx.reparentID != "" { b.WriteString(";p:") b.WriteString(ctx.reparentID) } @@ -1202,10 +1202,6 @@ func parseTracestate(ctx *spanContext, header string) { setPropagatingTag(ctx, "_dd.p."+keySuffix, val) } } - // if dd list-member is present and last parent is not set, set it to zeros - if ctx.reparentID == "" { - ctx.reparentID = "0000000000000000" - } } } diff --git a/ddtrace/tracer/textmap_test.go b/ddtrace/tracer/textmap_test.go index 6147821fcf..9575ac226d 100644 --- a/ddtrace/tracer/textmap_test.go +++ b/ddtrace/tracer/textmap_test.go @@ -1756,7 +1756,7 @@ func TestEnvVars(t *testing.T) { }, out: []uint64{8687463697196027922, 1311768467284833366}, priority: 1, - lastParent: "0000000000000000", + lastParent: "", }, } for i, tc := range tests { @@ -1839,7 +1839,13 @@ func TestEnvVars(t *testing.T) { if tc.priority != 0 { sctx.setSamplingPriority(int(tc.priority), samplernames.Unknown) } - assert.Equal(s.(*span).Meta["_dd.parent_id"], tc.lastParent) + + if tc.lastParent == "" { + assert.Empty(s.(*span).Meta["_dd.parent_id"]) + } else { + assert.Equal(s.(*span).Meta["_dd.parent_id"], tc.lastParent) + } + assert.Equal(true, sctx.updated) headers := TextMapCarrier(map[string]string{})