Skip to content

Commit

Permalink
Sort metric names in options for readability
Browse files Browse the repository at this point in the history
Generate the list of metrics names automatically to avoid it
getting out of date.
  • Loading branch information
eero-t authored and Paweł Szulik committed Jun 25, 2021
1 parent 8795a0e commit fc23546
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"runtime"
"sort"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -124,10 +125,11 @@ type metricSetValue struct {
}

func (ml *metricSetValue) String() string {
var values []string
values := make([]string, 0, len(ml.MetricSet))
for metric := range ml.MetricSet {
values = append(values, string(metric))
}
sort.Strings(values)
return strings.Join(values, ",")
}

Expand All @@ -147,7 +149,12 @@ func (ml *metricSetValue) Set(value string) error {
}

func init() {
flag.Var(&ignoreMetrics, "disable_metrics", "comma-separated list of `metrics` to be disabled. Options are 'accelerator', 'cpu_topology','disk', 'diskIO', 'memory_numa', 'network', 'tcp', 'udp', 'percpu', 'sched', 'process', 'hugetlb', 'referenced_memory', 'resctrl', 'cpuset'.")
opts := make([]string, 0, len(ignoreWhitelist))
for key := range ignoreWhitelist {
opts = append(opts, string(key))
}
sort.Strings(opts)
flag.Var(&ignoreMetrics, "disable_metrics", fmt.Sprintf("comma-separated list of `metrics` to be disabled. Options are '%s'.", strings.Join(opts, "', '")))

// Default logging verbosity to V(2)
flag.Set("v", "2")
Expand Down

0 comments on commit fc23546

Please sign in to comment.