git » prometheus-expvar-exporter » commit 540a838

Fail in a better way if there are no metrics in the config

author Alberto Bertogli
2019-10-31 21:01:39 UTC
committer Alberto Bertogli
2019-10-31 21:01:39 UTC
parent e9bf498cd860e5e90998a97bc59354c3127f8af5

Fail in a better way if there are no metrics in the config

main.go +3 -0

diff --git a/main.go b/main.go
index 4c582c0..537ffe7 100644
--- a/main.go
+++ b/main.go
@@ -42,6 +42,9 @@ func main() {
 			labelName: map[string]string{},
 		}
 
+		if !config.Has(t + ".m") {
+			continue
+		}
 		for _, name := range config.Get(t + ".m").(*toml.Tree).Keys() {
 			info := config.Get(t + ".m." + name).(*toml.Tree)
 			expvar := info.Get("expvar").(string)