diff --git a/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go b/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go index 757128f2b17..45910b97664 100644 --- a/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go +++ b/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go @@ -60,6 +60,9 @@ func main() { client := http.Client{ Transport: otelhttp.NewTransport( http.DefaultTransport, + // By setting the otelhttptrace client in this transport, it can be + // injected into the context after the span is started, which makes the + // httptrace spans childs of the transport one. otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace { return otelhttptrace.NewClientTrace(ctx) }),