diff --git a/pkg/engine/apicall/apiCall.go b/pkg/engine/apicall/apiCall.go index 41fca17c1f..fc91229a6e 100644 --- a/pkg/engine/apicall/apiCall.go +++ b/pkg/engine/apicall/apiCall.go @@ -17,6 +17,8 @@ import ( enginecontext "github.com/kyverno/kyverno/pkg/engine/context" "github.com/kyverno/kyverno/pkg/engine/jmespath" "github.com/kyverno/kyverno/pkg/engine/variables" + "github.com/kyverno/kyverno/pkg/tracing" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) type apiCall struct { @@ -163,19 +165,18 @@ func (a *apiCall) buildHTTPClient(service *kyvernov1.ServiceCall) (*http.Client, if service.CABundle == "" { return http.DefaultClient, nil } - caCertPool := x509.NewCertPool() if ok := caCertPool.AppendCertsFromPEM([]byte(service.CABundle)); !ok { return nil, fmt.Errorf("failed to parse PEM CA bundle for APICall %s", a.entry.Name) } - - return &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - RootCAs: caCertPool, - MinVersion: tls.VersionTLS12, - }, + transport := &http.Transport{ + TLSClientConfig: &tls.Config{ + RootCAs: caCertPool, + MinVersion: tls.VersionTLS12, }, + } + return &http.Client{ + Transport: tracing.Transport(transport, otelhttp.WithFilter(tracing.RequestFilterIsInSpan)), }, nil }