From f117cfca710ebcbe63f30b0f46207fac6d8ce53f Mon Sep 17 00:00:00 2001 From: zhouhaibing089 Date: Thu, 6 Jun 2024 22:50:28 -0700 Subject: [PATCH] webhook: remove resource_namespace tag in stats reporter This addresses #3171. As `resource_namespace` has the potential to contribute to high metrics cardinality while not adding much value from observability perspective, it would be ideal to disable it by default. --- cmd/webhook/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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()