fix: fixed the bug that old trace instances may be fetched

This commit is contained in:
chenquan
2023-02-22 17:21:58 +08:00
committed by Kevin Wan
parent 133c40ac1c
commit 3bc40d9eaf
6 changed files with 77 additions and 12 deletions

View File

@@ -156,12 +156,13 @@ func fillPath(u *nurl.URL, val map[string]any) error {
}
func request(r *http.Request, cli client) (*http.Response, error) {
tracer := otel.Tracer(trace.TraceName)
ctx := r.Context()
tracer := trace.TracerFromContext(ctx)
propagator := otel.GetTextMapPropagator()
spanName := r.URL.Path
ctx, span := tracer.Start(
r.Context(),
ctx,
spanName,
oteltrace.WithSpanKind(oteltrace.SpanKindClient),
oteltrace.WithAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...),