mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
a6c8c401ff
* feat: add signal in internal cmd package Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * logger Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
27 lines
698 B
Go
27 lines
698 B
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/go-logr/logr"
|
|
"github.com/kyverno/kyverno/pkg/tracing"
|
|
"k8s.io/client-go/kubernetes"
|
|
)
|
|
|
|
func SetupTracing(logger logr.Logger, name string, kubeClient kubernetes.Interface) context.CancelFunc {
|
|
logger = logger.WithName("tracing").WithValues("enabled", tracingEnabled, "address", tracingAddress, "port", tracingPort, "creds", tracingCreds)
|
|
if tracingEnabled {
|
|
logger.Info("setup tracing...")
|
|
shutdown, err := tracing.NewTraceConfig(
|
|
logger,
|
|
name,
|
|
net.JoinHostPort(tracingAddress, tracingPort),
|
|
tracingCreds,
|
|
kubeClient,
|
|
)
|
|
checkError(logger, err, "failed to setup tracing")
|
|
return shutdown
|
|
}
|
|
return func() {}
|
|
}
|