opentracing-contrib / go-stdlib

OpenTracing instrumentation for packages in the Go stdlib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why we need a root span?

cuihaikuo opened this issue · comments

When build a request and call TraceRequest(), two spans will be recorded, a root span and a child span, so why we use two spans to trace one request?

FWIW, this is what I see in Datadog, an empty HTTP_CLIENT root span that's not necessary:
image
image

Based on the code, I don't see where a root span could have been set other than in Tracer.start(req)

h.root = root

and AFAICT start only gets called once
tracer.start(req)

Was Tracer suppose to be initiated with a root span somehow but got missed

ht := &Tracer{tr: tr, opts: opts}

Like:

	ht := &Tracer{tr: tr, opts: opts, root: opentracing.SpanFromContext(req.Context())}

?