From 35ceb1d0f138428970c00f56a640e2db0773bf53 Mon Sep 17 00:00:00 2001 From: Tom Czarniecki Date: Thu, 3 Dec 2020 14:29:47 +1000 Subject: [PATCH] nicer help text creation --- scraper.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scraper.go b/scraper.go index ff51cbe..d3c6046 100644 --- a/scraper.go +++ b/scraper.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "strconv" + "strings" "time" "github.com/hashicorp/go-multierror" @@ -37,7 +38,7 @@ var ( prometheus.GaugeOpts{ Subsystem: "openldap", Name: "monitored_object", - Help: baseDN + " " + objectClass(monitoredObject) + " " + monitoredInfo, + Help: help(baseDN, objectClass(monitoredObject), monitoredInfo), }, []string{"dn"}, ) @@ -45,7 +46,7 @@ var ( prometheus.GaugeOpts{ Subsystem: "openldap", Name: "monitor_counter_object", - Help: baseDN + " " + objectClass(monitorCounterObject) + " " + monitorCounter, + Help: help(baseDN, objectClass(monitorCounterObject), monitorCounter), }, []string{"dn"}, ) @@ -53,7 +54,7 @@ var ( prometheus.GaugeOpts{ Subsystem: "openldap", Name: "monitor_operation", - Help: opsBaseDN + " " + objectClass(monitorOperation) + " " + monitorOpCompleted, + Help: help(opsBaseDN, objectClass(monitorOperation), monitorOpCompleted), }, []string{"dn"}, ) @@ -96,6 +97,10 @@ func init() { ) } +func help(msg ...string) string { + return strings.Join(msg, " ") +} + func objectClass(name string) string { return fmt.Sprintf("(objectClass=%v)", name) }