-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.go
38 lines (30 loc) · 1.34 KB
/
default.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package gotoprom
import (
"reflect"
"github.com/cabify/gotoprom/prometheusvanilla"
"github.com/prometheus/client_golang/prometheus"
)
// DefaultInitializer is the instance instance of the Initializer used by default
var DefaultInitializer = NewInitializer(prometheus.DefaultRegisterer)
func init() {
DefaultInitializer.MustAddBuilder(prometheusvanilla.HistogramType, prometheusvanilla.BuildHistogram)
DefaultInitializer.MustAddBuilder(prometheusvanilla.CounterType, prometheusvanilla.BuildCounter)
DefaultInitializer.MustAddBuilder(prometheusvanilla.GaugeType, prometheusvanilla.BuildGauge)
DefaultInitializer.MustAddBuilder(prometheusvanilla.SummaryType, prometheusvanilla.BuildSummary)
}
// MustAddBuilder will AddBuilder and panic if an error occurs
func MustAddBuilder(typ reflect.Type, registerer Builder) {
DefaultInitializer.MustAddBuilder(typ, registerer)
}
// AddBuilder adds a new registerer for type typ.
func AddBuilder(typ reflect.Type, registerer Builder) error {
return DefaultInitializer.AddBuilder(typ, registerer)
}
// MustInit initializes the metrics or panics.
func MustInit(metrics interface{}, namespace string) {
DefaultInitializer.MustInit(metrics, namespace)
}
// Init initializes the metrics in the given namespace.
func Init(metrics interface{}, namespace string) error {
return DefaultInitializer.Init(metrics, namespace)
}