@@ -21,6 +21,7 @@ import (
21
21
22
22
"github.com/golang/protobuf/proto"
23
23
24
+ "github.com/prometheus/client_golang/model"
24
25
dto "github.com/prometheus/client_model/go"
25
26
)
26
27
@@ -33,7 +34,7 @@ import (
33
34
//
34
35
// Note that Histograms, in contrast to Summaries, can be aggregated with the
35
36
// Prometheus query language (see the documentation for detailed
36
- // procedures). However, Histograms requires the user to pre-define suitable
37
+ // procedures). However, Histograms require the user to pre-define suitable
37
38
// buckets, and they are in general less accurate. The Observe method of a
38
39
// Histogram has a very low performance overhead in comparison with the Observe
39
40
// method of a Summary.
@@ -47,12 +48,16 @@ type Histogram interface {
47
48
Observe (float64 )
48
49
}
49
50
50
- // DefBuckets are the default Histogram buckets. The default buckets are
51
- // tailored to broadly measure response time in seconds for a typical online
52
- // serving system. Most likely, however, you will be required to define buckets
53
- // customized to your use case.
54
51
var (
52
+ // DefBuckets are the default Histogram buckets. The default buckets are
53
+ // tailored to broadly measure response time in seconds for a typical online
54
+ // serving system. Most likely, however, you will be required to define buckets
55
+ // customized to your use case.
55
56
DefBuckets = []float64 {.005 , .01 , .025 , .05 , .1 , .25 , .5 , 1 , 2.5 , 5 , 10 }
57
+
58
+ errBucketLabelNotAllowed = fmt .Errorf (
59
+ "%q is not allowed as label name in histograms" , model .BucketLabel ,
60
+ )
56
61
)
57
62
58
63
// LinearBuckets creates 'count' buckets, each 'width' wide, where the lowest
@@ -165,13 +170,13 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
165
170
}
166
171
167
172
for _ , n := range desc .variableLabels {
168
- if n == "le" {
169
- panic ("'le' is not allowed as label name in histograms" )
173
+ if n == model . BucketLabel {
174
+ panic (errBucketLabelNotAllowed )
170
175
}
171
176
}
172
177
for _ , lp := range desc .constLabelPairs {
173
- if lp .GetName () == "le" {
174
- panic ("'le' is not allowed as label name in histograms" )
178
+ if lp .GetName () == model . BucketLabel {
179
+ panic (errBucketLabelNotAllowed )
175
180
}
176
181
}
177
182
0 commit comments