Sort collector names.

This makes the `-collectors.print` output easier to read.
This commit is contained in:
Matthias Rampke 2015-05-12 15:04:08 +00:00
parent b4f40ab13f
commit 57a6701dc9
1 changed files with 7 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"os/signal" "os/signal"
"sort"
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
@ -142,8 +143,13 @@ func main() {
flag.Parse() flag.Parse()
if *printCollectors { if *printCollectors {
fmt.Printf("Available collectors:\n") collectorNames := make(sort.StringSlice, 0, len(collector.Factories))
for n, _ := range collector.Factories { for n, _ := range collector.Factories {
collectorNames = append(collectorNames, n)
}
collectorNames.Sort()
fmt.Printf("Available collectors:\n")
for _, n := range collectorNames {
fmt.Printf(" - %s\n", n) fmt.Printf(" - %s\n", n)
} }
return return