Add HTTP client update function to tracing library

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2023-12-06 11:16:48 -08:00
parent ad3b806a4f
commit 8203bb9977
2 changed files with 14 additions and 7 deletions

View File

@@ -39,7 +39,6 @@ import (
"github.com/containerd/log"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
var (
@@ -596,12 +595,9 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
return nil
}
}
client.Transport = otelhttp.NewTransport(
client.Transport,
otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
return tracing.Name("remotes.docker.resolver", "HTTPRequest")
}),
)
tracing.UpdateHTTPClient(client, tracing.Name("remotes.docker.resolver", "HTTPRequest"))
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to do request: %w", err)