From 7e46b15957699eebcdc9c57002aac6191c5eaaf5 Mon Sep 17 00:00:00 2001 From: Maryam Tahhan Date: Wed, 31 Jul 2024 07:31:05 -0400 Subject: [PATCH] refactor: bpfSupportedMetrics usage in NewStats() Remove the need to pass bpfSupportedMetrics through n layers of function calls that lead to NewStats() by adding a reasonable default set of bpfmetrics that the exporter will/can then override when it's started. Signed-off-by: Maryam Tahhan --- pkg/collector/stats/utils.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/collector/stats/utils.go b/pkg/collector/stats/utils.go index 32959ba53d..1bb9c373a2 100644 --- a/pkg/collector/stats/utils.go +++ b/pkg/collector/stats/utils.go @@ -22,6 +22,7 @@ import ( "os/exec" "regexp" "runtime" + "slices" "strconv" "strings" @@ -92,6 +93,10 @@ func GetProcessFeatureNames(bpfSupportedMetrics bpf.SupportedMetrics) []string { return metrics } +func AvailableBPFMetricsHas(s string) bool { + return slices.Contains(AvailableBPFMetrics, s) +} + func GetNodeName() string { if nodeName := os.Getenv("NODE_NAME"); nodeName != "" { return nodeName