Skip to content

Commit b342642

Browse files
eero-tPaweł Szulik
authored andcommitted
Remove toIncludedMetrics() one-liner
Inlining container.AllMetrics.Difference() call makes the code intent more explicit, and is about same amount of code.
1 parent 4922785 commit b342642

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

cmd/cadvisor.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func main() {
121121
if len(enableMetrics) > 0 {
122122
includedMetrics = enableMetrics
123123
} else {
124-
includedMetrics = toIncludedMetrics(ignoreMetrics)
124+
includedMetrics = container.AllMetrics.Difference(ignoreMetrics)
125125
}
126126
klog.V(1).Infof("enabled metrics: %s", includedMetrics.String())
127127
setMaxProcs()
@@ -239,7 +239,3 @@ func createCollectorHttpClient(collectorCert, collectorKey string) http.Client {
239239

240240
return http.Client{Transport: transport}
241241
}
242-
243-
func toIncludedMetrics(ignoreMetrics container.MetricSet) container.MetricSet {
244-
return container.AllMetrics.Difference(ignoreMetrics)
245-
}

cmd/cadvisor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func TestToIncludedMetrics(t *testing.T) {
118118
}
119119

120120
for idx, ignore := range ignores {
121-
actual := toIncludedMetrics(ignore)
121+
actual := container.AllMetrics.Difference(ignore)
122122
assert.Equal(t, actual, expected[idx])
123123
}
124124
}

0 commit comments

Comments
 (0)