@@ -33,7 +33,7 @@ const (
33
33
)
34
34
35
35
// DefaultRegistry is a Registry instance that has a ProcessCollector and a
36
- // GoCollector pre-registered. DefaultRegisterer and DefaultDeliverer are both
36
+ // GoCollector pre-registered. DefaultRegisterer and DefaultGatherer are both
37
37
// pointing to it. A number of convenience functions in this package act on
38
38
// them. This approach to keep a default instance as global state mirrors the
39
39
// approach of other packages in the Go standard library. Note that there are
@@ -43,7 +43,7 @@ const (
43
43
var (
44
44
DefaultRegistry = NewRegistry ()
45
45
DefaultRegisterer Registerer = DefaultRegistry
46
- DefaultDeliverer Deliverer = DefaultRegistry
46
+ DefaultGatherer Gatherer = DefaultRegistry
47
47
)
48
48
49
49
func init () {
@@ -115,24 +115,23 @@ type Registerer interface {
115
115
Unregister (Collector ) bool
116
116
}
117
117
118
- // Deliverer is the interface for the part of a registry in charge of delivering
119
- // the collected metrics, wich the same general implication as described for the
120
- // Registerer interface.
121
- type Deliverer interface {
122
- // Deliver collects metrics from registered Collectors and returns them
123
- // as lexicographically sorted MetricFamily protobufs. Even if an error
124
- // occurs, Deliver attempts to collect as many metrics as
125
- // possible. Hence, if a non-nil error is returned, the returned
126
- // MetricFamily slice could be nil (in case of a fatal error that
127
- // prevented any meaningful metric collection) or contain a number of
128
- // MetricFamily protobufs, some of which might be incomplete, and some
129
- // might be missing altogether. The returned error (which might be a
130
- // multierror.Error) explains the details. In any case, the MetricFamily
131
- // protobufs are consistent and valid for Prometheus to ingest (e.g. no
132
- // duplicate metrics, no invalid identifiers). In scenarios where
133
- // complete collection is critical, the returned MetricFamily protobufs
134
- // should be disregarded if the returned error is non-nil.
135
- Deliver () ([]* dto.MetricFamily , error )
118
+ // Gatherer is the interface for the part of a registry in charge of gathering
119
+ // the collected metrics into a number of MetricFamilies. The Gatherer interface
120
+ // comes with the same general implication as described for the Registerer
121
+ // interface.
122
+ type Gatherer interface {
123
+ // Gather calls the Collect method of the registered Collectors and then
124
+ // gathers the collected metrics into a lexicographically sorted slice
125
+ // of MetricFamily protobufs. Even if an error occurs, Gather attempts
126
+ // to gather as many metrics as possible. Hence, if a non-nil error is
127
+ // returned, the returned MetricFamily slice could be nil (in case of a
128
+ // fatal error that prevented any meaningful metric collection) or
129
+ // contain a number of MetricFamily protobufs, some of which might be
130
+ // incomplete, and some might be missing altogether. The returned error
131
+ // (which might be a MultiError) explains the details. In scenarios
132
+ // where complete collection is critical, the returned MetricFamily
133
+ // protobufs should be disregarded if the returned error is non-nil.
134
+ Gather () ([]* dto.MetricFamily , error )
136
135
}
137
136
138
137
// Register registers the provided Collector with the DefaultRegisterer.
@@ -221,10 +220,10 @@ func (err AlreadyRegisteredError) Error() string {
221
220
return "duplicate metrics collector registration attempted"
222
221
}
223
222
224
- // Registry registers Prometheus collectors, collects their metrics, and
225
- // delivers them for exposition. It implements Registerer and Deliverer. The
226
- // zero value is not usable. Use NewRegistry or NewPedanticRegistry to create
227
- // instances .
223
+ // Registry registers Prometheus collectors, collects their metrics, and gathers
224
+ // them into MetricFamilies for exposition. It implements Registerer and
225
+ // Gatherer. The zero value is not usable. Create instances with NewRegistry or
226
+ // NewPedanticRegistry .
228
227
type Registry struct {
229
228
mtx sync.RWMutex
230
229
collectorsByID map [uint64 ]Collector // ID is a hash of the descIDs.
@@ -361,8 +360,8 @@ func (r *Registry) MustRegister(cs ...Collector) {
361
360
}
362
361
}
363
362
364
- // Deliver implements Deliverer .
365
- func (r * Registry ) Deliver () ([]* dto.MetricFamily , error ) {
363
+ // Gather implements Gatherer .
364
+ func (r * Registry ) Gather () ([]* dto.MetricFamily , error ) {
366
365
var (
367
366
metricChan = make (chan Metric , capMetricChan )
368
367
metricHashes = map [uint64 ]struct {}{}
0 commit comments