Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
nicer help text creation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcz committed Dec 3, 2020
1 parent 5948609 commit 35ceb1d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -37,23 +38,23 @@ var (
prometheus.GaugeOpts{
Subsystem: "openldap",
Name: "monitored_object",
Help: baseDN + " " + objectClass(monitoredObject) + " " + monitoredInfo,
Help: help(baseDN, objectClass(monitoredObject), monitoredInfo),
},
[]string{"dn"},
)
monitorCounterObjectGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Subsystem: "openldap",
Name: "monitor_counter_object",
Help: baseDN + " " + objectClass(monitorCounterObject) + " " + monitorCounter,
Help: help(baseDN, objectClass(monitorCounterObject), monitorCounter),
},
[]string{"dn"},
)
monitorOperationGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Subsystem: "openldap",
Name: "monitor_operation",
Help: opsBaseDN + " " + objectClass(monitorOperation) + " " + monitorOpCompleted,
Help: help(opsBaseDN, objectClass(monitorOperation), monitorOpCompleted),
},
[]string{"dn"},
)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 35ceb1d

Please sign in to comment.