Skip to content

Commit

Permalink
webhook: remove resource_namespace tag in stats reporter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zhouhaibing089 committed Jun 21, 2024
1 parent 9760223 commit f117cfc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -253,6 +259,8 @@ func main() {
ServiceName: serviceName,
Port: webhook.PortFromEnv(8443),
SecretName: secretName,

StatsReporterOptions: statsReporterOptions,
})

mux := http.NewServeMux()
Expand Down

0 comments on commit f117cfc

Please sign in to comment.