Merge pull request #529 from martinlindhe/check-collector-exists

Check that collectors given on --collectors.enabled exist before trying to construct them
This commit is contained in:
Calle Pettersson 2020-05-24 20:04:02 +02:00 committed by GitHub
commit f8f34ab983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package collector
import (
"fmt"
"strconv"
"strings"
@ -72,7 +73,11 @@ func Available() []string {
return cs
}
func Build(collector string) (Collector, error) {
return builders[collector]()
builder, exists := builders[collector]
if !exists {
return nil, fmt.Errorf("Unknown collector %q", collector)
}
return builder()
}
func getPerfQuery(collectors []string) string {
parts := make([]string, 0, len(collectors))