diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index 7281f0af421..4b54c0d4390 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -245,6 +245,12 @@ func main() { webhookName = "webhook.pipeline.tekton.dev" } + var statsReporterOptions []webhook.StatsReporterOption + enableNamespace := os.Getenv("WEBHOOK_METRICS_ENABLE_NAMESPACE") + if enableNamespace != "true" { + statsReporterOptions = append(statsReporterOptions, webhook.WithoutTags("resource_namespace")) + } + // Scope informers to the webhook's namespace instead of cluster-wide ctx := injection.WithNamespaceScope(signals.NewContext(), system.Namespace()) @@ -253,6 +259,8 @@ func main() { ServiceName: serviceName, Port: webhook.PortFromEnv(8443), SecretName: secretName, + + StatsReporterOptions: statsReporterOptions, }) mux := http.NewServeMux()