Skip to content

Commit

Permalink
refactor: bpfSupportedMetrics usage in NewStats()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
maryamtahhan committed Sep 2, 2024
1 parent 0433ade commit 7e46b15
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/collector/stats/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os/exec"
"regexp"
"runtime"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -92,6 +93,10 @@ func GetProcessFeatureNames(bpfSupportedMetrics bpf.SupportedMetrics) []string {
return metrics
}

func AvailableBPFMetricsHas(s string) bool {
return slices.Contains(AvailableBPFMetrics, s)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

undefined: AvailableBPFMetrics) (typecheck)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

undefined: AvailableBPFMetrics) (typecheck)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / lint

undefined: AvailableBPFMetrics) (typecheck)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / govet_test

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / govet_test

undefined: AvailableBPFMetrics

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / govet_test

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / golang / govet_test

undefined: AvailableBPFMetrics

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / unit_test / unit_test

cannot infer S ($GOROOT/src/slices/slices.go:115:15)

Check failure on line 97 in pkg/collector/stats/utils.go

View workflow job for this annotation

GitHub Actions / unit_test / unit_test

undefined: AvailableBPFMetrics
}

func GetNodeName() string {
if nodeName := os.Getenv("NODE_NAME"); nodeName != "" {
return nodeName
Expand Down

0 comments on commit 7e46b15

Please sign in to comment.