From 2ea20ff62872ef2a10687511ac413417340499eb Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Sun, 24 May 2020 17:23:13 +0200 Subject: [PATCH] Check that collectors given on --collectors.enabled exist before trying to construct them --- collector/collector.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/collector/collector.go b/collector/collector.go index edcb880b..97812d76 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -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))