New filters on the Home Feed, take a look!
view details

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.

1
Help with Tracing in My Application - Lost Parent Span for HTTP Client Spans
Post Flair (click to view more posts with a particular flair)
Post Body

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
}

Author
Account Strength
40%
Account Age
10 months
Verified Email
Yes
Verified Flair
No
Total Karma
28
Link Karma
21
Comment Karma
7
Profile updated: 10 hours ago
Posts updated: 1 week ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 months ago