-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
When i used nethttp,create span twice,I don't think it makes sense
req, ht := nethttp.TraceRequest(c.Tracer, req, nethttp.OperationName("HTTP GET: "+endpoint))
defer ht.Finish()
Then I look at the source code
func (h *Tracer) start(req *http.Request) opentracing.Span {
if h.root == nil {
parent := opentracing.SpanFromContext(req.Context())
var spanctx opentracing.SpanContext
if parent != nil {
spanctx = parent.Context()
}
operationName := h.opts.operationName
if operationName == "" {
operationName = "HTTP Client"
}
root := h.tr.StartSpan(operationName, opentracing.ChildOf(spanctx))
h.root = root
}
ctx := h.root.Context()
h.sp = h.tr.StartSpan("HTTP "+req.Method, opentracing.ChildOf(ctx))
ext.SpanKindRPCClient.Set(h.sp)
componentName := h.opts.componentName
if componentName == "" {
componentName = defaultComponentName
}
ext.Component.Set(h.sp, componentName)
return h.sp
}
I don't understand why span h.sp is created
iamnoah
Metadata
Metadata
Assignees
Labels
No labels