@@ -15,15 +15,15 @@ package prometheus
15
15
16
16
// Collector is the interface implemented by anything that can be used by
17
17
// Prometheus to collect metrics. A Collector has to be registered for
18
- // collection. See Register, MustRegister, RegisterOrGet, and MustRegisterOrGet .
18
+ // collection. See Registerer. Register.
19
19
//
20
- // The stock metrics provided by this package (like Gauge, Counter, Summary) are
21
- // also Collectors (which only ever collect one metric, namely itself). An
22
- // implementer of Collector may, however, collect multiple metrics in a
23
- // coordinated fashion and/or create metrics on the fly. Examples for collectors
24
- // already implemented in this library are the metric vectors (i.e. collection
25
- // of multiple instances of the same Metric but with different label values)
26
- // like GaugeVec or SummaryVec, and the ExpvarCollector.
20
+ // The stock metrics provided by this package (Gauge, Counter, Summary,
21
+ // Histogram, Untyped) are also Collectors (which only ever collect one metric,
22
+ // namely itself). An implementer of Collector may, however, collect multiple
23
+ // metrics in a coordinated fashion and/or create metrics on the fly. Examples
24
+ // for collectors already implemented in this library are the metric vectors
25
+ // (i.e. collection of multiple instances of the same Metric but with different
26
+ // label values) like GaugeVec or SummaryVec, and the ExpvarCollector.
27
27
type Collector interface {
28
28
// Describe sends the super-set of all possible descriptors of metrics
29
29
// collected by this Collector to the provided channel and returns once
@@ -37,39 +37,39 @@ type Collector interface {
37
37
// executing this method, it must send an invalid descriptor (created
38
38
// with NewInvalidDesc) to signal the error to the registry.
39
39
Describe (chan <- * Desc )
40
- // Collect is called by Prometheus when collecting metrics. The
41
- // implementation sends each collected metric via the provided channel
42
- // and returns once the last metric has been sent. The descriptor of
43
- // each sent metric is one of those returned by Describe. Returned
44
- // metrics that share the same descriptor must differ in their variable
45
- // label values. This method may be called concurrently and must
46
- // therefore be implemented in a concurrency safe way. Blocking occurs
47
- // at the expense of total performance of rendering all registered
48
- // metrics. Ideally, Collector implementations support concurrent
49
- // readers.
40
+ // Collect is called by the Prometheus registry when collecting
41
+ // metrics. The implementation sends each collected metric via the
42
+ // provided channel and returns once the last metric has been sent. The
43
+ // descriptor of each sent metric is one of those returned by
44
+ // Describe. Returned metrics that share the same descriptor must differ
45
+ // in their variable label values. This method may be called
46
+ // concurrently and must therefore be implemented in a concurrency safe
47
+ // way. Blocking occurs at the expense of total performance of rendering
48
+ // all registered metrics. Ideally, Collector implementations support
49
+ // concurrent readers.
50
50
Collect (chan <- Metric )
51
51
}
52
52
53
- // SelfCollector implements Collector for a single Metric so that that the
54
- // Metric collects itself. Add it as an anonymous field to a struct that
55
- // implements Metric, and call Init with the Metric itself as an argument.
56
- type SelfCollector struct {
53
+ // selfCollector implements Collector for a single Metric so that the Metric
54
+ // collects itself. Add it as an anonymous field to a struct that implements
55
+ // Metric, and call init with the Metric itself as an argument.
56
+ type selfCollector struct {
57
57
self Metric
58
58
}
59
59
60
- // Init provides the SelfCollector with a reference to the metric it is supposed
60
+ // init provides the selfCollector with a reference to the metric it is supposed
61
61
// to collect. It is usually called within the factory function to create a
62
62
// metric. See example.
63
- func (c * SelfCollector ) Init (self Metric ) {
63
+ func (c * selfCollector ) init (self Metric ) {
64
64
c .self = self
65
65
}
66
66
67
67
// Describe implements Collector.
68
- func (c * SelfCollector ) Describe (ch chan <- * Desc ) {
68
+ func (c * selfCollector ) Describe (ch chan <- * Desc ) {
69
69
ch <- c .self .Desc ()
70
70
}
71
71
72
72
// Collect implements Collector.
73
- func (c * SelfCollector ) Collect (ch chan <- Metric ) {
73
+ func (c * selfCollector ) Collect (ch chan <- Metric ) {
74
74
ch <- c .self
75
75
}
0 commit comments