This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hello everyone,
I've recently set up tracing in my application to monitor and debug the flow of requests. Everything seemed to be working fine, but I've encountered a peculiar issue with my HTTP client.
The issue: When there is an error in the HTTP request, the tracing works as expected, and I can see the parent span properly linked to the HTTP client spans. However, when the HTTP request completes successfully (without any errors), I lose the parent span of the HTTP client spans but still get them unattached with warning invalid parent span IDs.
Thank you in advance!
this is the the httpClient I'm using:
transport := traceHttp.NewTracedTransport(nil, otel.GetTracerProvider())
httpClient:= http.Client{Transport: transport}
and the library:
package http
import (
"context"
"net/http"
"net/http/httptrace"
"go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/trace"
)
func NewTracedTransport(transport http.RoundTripper,provider trace.TracerProvider) *otelhttp.Transport {
if transport == nil {
transport = http.DefaultTransport
}
return otelhttp.NewTransport(
transport,
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
return otelhttptrace.NewClientTrace(ctx)
}), otelhttp.WithTracerProvider(provider),otelhttp.WithSpanNameFormatter(name),
)
}
func name(_ string, req *http.Request) string {
return "HTTP " req.Method " " req.URL.Path
}
Subreddit
Post Details
- Posted
- 7 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/golang/comm...