Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why create span twice #61

Open
wuyouyu1992 opened this issue Jul 13, 2021 · 0 comments
Open

why create span twice #61

wuyouyu1992 opened this issue Jul 13, 2021 · 0 comments

Comments

@wuyouyu1992
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant