git » prometheus-expvar-exporter » commit bc1cd03

Collect even if there are no metrics defined

author Alberto Bertogli
2019-10-31 21:06:18 UTC
committer Alberto Bertogli
2019-10-31 21:06:18 UTC
parent 540a83802b51e293ec8e5d3a26d32fb76d5bb261

Collect even if there are no metrics defined

The previous bug fix wasn't right, as it now skips the collector
completely; this patch fixes the problem.

main.go +2 -4

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