forked from mirror/client_golang
Merge pull request #393 from athomason/promauto-funcs
promauto: add NewCounterFunc and NewGaugeFunc
This commit is contained in:
commit
07e5c3ca88
|
@ -147,6 +147,16 @@ func NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCounterFunc works like the function of the same name in the prometheus
|
||||||
|
// package but it automatically registers the CounterFunc with the
|
||||||
|
// prometheus.DefaultRegisterer. If the registration fails, NewCounterFunc
|
||||||
|
// panics.
|
||||||
|
func NewCounterFunc(opts prometheus.CounterOpts, function func() float64) prometheus.CounterFunc {
|
||||||
|
g := prometheus.NewCounterFunc(opts, function)
|
||||||
|
prometheus.MustRegister(g)
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
|
||||||
// NewGauge works like the function of the same name in the prometheus package
|
// NewGauge works like the function of the same name in the prometheus package
|
||||||
// but it automatically registers the Gauge with the
|
// but it automatically registers the Gauge with the
|
||||||
// prometheus.DefaultRegisterer. If the registration fails, NewGauge panics.
|
// prometheus.DefaultRegisterer. If the registration fails, NewGauge panics.
|
||||||
|
@ -165,6 +175,15 @@ func NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.Gau
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewGaugeFunc works like the function of the same name in the prometheus
|
||||||
|
// package but it automatically registers the GaugeFunc with the
|
||||||
|
// prometheus.DefaultRegisterer. If the registration fails, NewGaugeFunc panics.
|
||||||
|
func NewGaugeFunc(opts prometheus.GaugeOpts, function func() float64) prometheus.GaugeFunc {
|
||||||
|
g := prometheus.NewGaugeFunc(opts, function)
|
||||||
|
prometheus.MustRegister(g)
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
|
||||||
// NewSummary works like the function of the same name in the prometheus package
|
// NewSummary works like the function of the same name in the prometheus package
|
||||||
// but it automatically registers the Summary with the
|
// but it automatically registers the Summary with the
|
||||||
// prometheus.DefaultRegisterer. If the registration fails, NewSummary panics.
|
// prometheus.DefaultRegisterer. If the registration fails, NewSummary panics.
|
||||||
|
|
Loading…
Reference in New Issue