mirror of https://github.com/k3s-io/k3s
Ensure prometheus metrics are not registered twice
Change-Id: I0f05fae65689b1e22c18d2c46dc5125780e81024pull/564/head
parent
07428f7e5d
commit
8fa332cce3
|
@ -16,7 +16,11 @@ limitations under the License.
|
|||
|
||||
package aws
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
awsAPIMetric = prometheus.NewHistogramVec(
|
||||
|
@ -53,8 +57,12 @@ func recordAWSThrottlesMetric(operation string) {
|
|||
awsAPIThrottlesMetric.With(prometheus.Labels{"operation_name": operation}).Inc()
|
||||
}
|
||||
|
||||
var registerOnce sync.Once
|
||||
|
||||
func registerMetrics() {
|
||||
prometheus.MustRegister(awsAPIMetric)
|
||||
prometheus.MustRegister(awsAPIErrorMetric)
|
||||
prometheus.MustRegister(awsAPIThrottlesMetric)
|
||||
registerOnce.Do(func() {
|
||||
prometheus.MustRegister(awsAPIMetric)
|
||||
prometheus.MustRegister(awsAPIErrorMetric)
|
||||
prometheus.MustRegister(awsAPIThrottlesMetric)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -16,7 +16,11 @@ limitations under the License.
|
|||
|
||||
package openstack
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
openstackSubsystem = "openstack"
|
||||
|
@ -44,7 +48,11 @@ var (
|
|||
)
|
||||
)
|
||||
|
||||
var registerOnce sync.Once
|
||||
|
||||
func registerMetrics() {
|
||||
prometheus.MustRegister(openstackOperationsLatency)
|
||||
prometheus.MustRegister(openstackAPIRequestErrors)
|
||||
registerOnce.Do(func() {
|
||||
prometheus.MustRegister(openstackOperationsLatency)
|
||||
prometheus.MustRegister(openstackAPIRequestErrors)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue