Skip to content

Commit b25ce26

Browse files
authored
Merge pull request #713 from prometheus/beorn7/promauto
Add a "factory" to make promauto work for custom registries
2 parents 110f6d4 + 1c2884b commit b25ce26

File tree

3 files changed

+248
-97
lines changed

3 files changed

+248
-97
lines changed

prometheus/doc.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,21 @@
8484
// of those four metric types can be found in the Prometheus docs:
8585
// https://prometheus.io/docs/concepts/metric_types/
8686
//
87-
// A fifth "type" of metric is Untyped. It behaves like a Gauge, but signals the
88-
// Prometheus server not to assume anything about its type.
89-
//
90-
// In addition to the fundamental metric types Gauge, Counter, Summary,
91-
// Histogram, and Untyped, a very important part of the Prometheus data model is
92-
// the partitioning of samples along dimensions called labels, which results in
87+
// In addition to the fundamental metric types Gauge, Counter, Summary, and
88+
// Histogram, a very important part of the Prometheus data model is the
89+
// partitioning of samples along dimensions called labels, which results in
9390
// metric vectors. The fundamental types are GaugeVec, CounterVec, SummaryVec,
94-
// HistogramVec, and UntypedVec.
91+
// and HistogramVec.
9592
//
9693
// While only the fundamental metric types implement the Metric interface, both
9794
// the metrics and their vector versions implement the Collector interface. A
9895
// Collector manages the collection of a number of Metrics, but for convenience,
99-
// a Metric can also “collect itself”. Note that Gauge, Counter, Summary,
100-
// Histogram, and Untyped are interfaces themselves while GaugeVec, CounterVec,
101-
// SummaryVec, HistogramVec, and UntypedVec are not.
96+
// a Metric can also “collect itself”. Note that Gauge, Counter, Summary, and
97+
// Histogram are interfaces themselves while GaugeVec, CounterVec, SummaryVec,
98+
// and HistogramVec are not.
10299
//
103100
// To create instances of Metrics and their vector versions, you need a suitable
104-
// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, HistogramOpts, or
105-
// UntypedOpts.
101+
// …Opts struct, i.e. GaugeOpts, CounterOpts, SummaryOpts, or HistogramOpts.
106102
//
107103
// Custom Collectors and constant Metrics
108104
//
@@ -118,13 +114,16 @@
118114
// existing numbers into Prometheus Metrics during collection. An own
119115
// implementation of the Collector interface is perfect for that. You can create
120116
// Metric instances “on the fly” using NewConstMetric, NewConstHistogram, and
121-
// NewConstSummary (and their respective Must… versions). That will happen in
122-
// the Collect method. The Describe method has to return separate Desc
123-
// instances, representative of the “throw-away” metrics to be created later.
124-
// NewDesc comes in handy to create those Desc instances. Alternatively, you
125-
// could return no Desc at all, which will mark the Collector “unchecked”. No
126-
// checks are performed at registration time, but metric consistency will still
127-
// be ensured at scrape time, i.e. any inconsistencies will lead to scrape
117+
// NewConstSummary (and their respective Must… versions). NewConstMetric is used
118+
// for all metric types with just a float64 as their value: Counter, Gauge, and
119+
// a special “type” called Untyped. Use the latter if you are not sure if the
120+
// mirrored metric is a Counter or a Gauge. Creation of the Metric instance
121+
// happens in the Collect method. The Describe method has to return separate
122+
// Desc instances, representative of the “throw-away” metrics to be created
123+
// later. NewDesc comes in handy to create those Desc instances. Alternatively,
124+
// you could return no Desc at all, which will mark the Collector “unchecked”.
125+
// No checks are performed at registration time, but metric consistency will
126+
// still be ensured at scrape time, i.e. any inconsistencies will lead to scrape
128127
// errors. Thus, with unchecked Collectors, the responsibility to not collect
129128
// metrics that lead to inconsistencies in the total scrape result lies with the
130129
// implementer of the Collector. While this is not a desirable state, it is

0 commit comments

Comments
 (0)