Files
moby/distribution/transport.go
Paweł Gronowski 93e9f7f75f distribution: Pass Traceparent OTEL HTTP header
Wrap `http.RoundTripper` used by distribution code (push/pull) with the
`otelhttp.Transport`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-20 15:49:09 +01:00

19 lines
569 B
Go

package distribution
import (
"net/http"
"github.com/docker/distribution/registry/client/transport"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)
// newTransport creates a new transport which will apply modifiers to
// the request on a RoundTrip call.
func newTransport(base http.RoundTripper, modifiers ...transport.RequestModifier) http.RoundTripper {
tr := transport.NewTransport(base, modifiers...)
// Wrap the transport with OpenTelemetry instrumentation
// This propagates the Traceparent header.
return otelhttp.NewTransport(tr)
}