From bf84d28324f1fef11f5dbb39dc6a003d489078d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Casta=C3=B1=C3=A9?= Date: Fri, 20 Dec 2024 10:38:43 +0100 Subject: [PATCH] fix(ddtrace/tracer): avoid panic on nil spancontext on Extract --- ddtrace/tracer/textmap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddtrace/tracer/textmap.go b/ddtrace/tracer/textmap.go index b1b49385fc..06f7589c9a 100644 --- a/ddtrace/tracer/textmap.go +++ b/ddtrace/tracer/textmap.go @@ -291,7 +291,7 @@ func (p *chainedPropagator) Extract(carrier interface{}) (*SpanContext, error) { overrideDatadogParentID(ctx2, extractedCtx2, ddCtx) } } - } else { // Trace IDs do not match - create span links + } else if extractedCtx2 != nil { // Trace IDs do not match - create span links link := SpanLink{TraceID: extractedCtx2.TraceIDLower(), SpanID: extractedCtx2.SpanID(), TraceIDHigh: extractedCtx2.TraceIDUpper(), Attributes: map[string]string{"reason": "terminated_context", "context_headers": getPropagatorName(v)}} if trace := extractedCtx2.trace; trace != nil { if flags := uint32(*trace.priority); flags > 0 { // Set the flags based on the sampling priority