metrics: correctly register all metrics (#1335)
After initial startup, see if prometheus is loaded and if so, register our metrics with it. Stop doing the init() func and just use the sync.Once so we don't double registrer our metrics.
This commit is contained in:
parent
5ac42ed5c2
commit
90dd4bbd45
8 changed files with 76 additions and 45 deletions
|
@ -25,15 +25,6 @@ var (
|
|||
}, []string{"proto", "proxy_proto", "family", "to"})
|
||||
)
|
||||
|
||||
// OnStartupMetrics sets up the metrics on startup. This is done for all proxy protocols.
|
||||
func OnStartupMetrics() error {
|
||||
metricsOnce.Do(func() {
|
||||
prometheus.MustRegister(RequestCount)
|
||||
prometheus.MustRegister(RequestDuration)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// familyToString returns the string form of either 1, or 2. Returns
|
||||
// empty string is not a known family
|
||||
func familyToString(f int) string {
|
||||
|
@ -46,4 +37,4 @@ func familyToString(f int) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
var metricsOnce sync.Once
|
||||
var once sync.Once
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue