aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Rabenstein <bjoern@rabenste.in>2018-10-05 16:05:02 +0200
committerBen Kochie <superq@gmail.com>2018-10-05 16:05:02 +0200
commitbddf41d327d6f2148e5ba27c8bc1fd5c4f02e20e (patch)
treebf1809f56354fd2d0e1fa3f9878a383aba6561a3
parent01ec8c5c5c3636a52d6f9e7c6f6cebaeb9f07af4 (diff)
downloadprometheus_node_collector-bddf41d327d6f2148e5ba27c8bc1fd5c4f02e20e.tar.bz2
prometheus_node_collector-bddf41d327d6f2148e5ba27c8bc1fd5c4f02e20e.tar.xz
prometheus_node_collector-bddf41d327d6f2148e5ba27c8bc1fd5c4f02e20e.zip
Update prometheus/client_golang vendoring (#1099)
This is mostly required to fix a bug with histograms on 32bit platforms. (Which might or might not be used in node_exporter. Just in case...) Signed-off-by: beorn7 <beorn@soundcloud.com>
-rw-r--r--vendor/github.com/prometheus/client_golang/prometheus/collector.go3
-rw-r--r--vendor/github.com/prometheus/client_golang/prometheus/histogram.go45
-rw-r--r--vendor/github.com/prometheus/client_golang/prometheus/registry.go37
-rw-r--r--vendor/vendor.json14
4 files changed, 59 insertions, 40 deletions
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/collector.go b/vendor/github.com/prometheus/client_golang/prometheus/collector.go
index 08491be..c0d70b2 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/collector.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/collector.go
@@ -40,7 +40,8 @@ type Collector interface {
40 // Collector may yield any Metric it sees fit in its Collect method. 40 // Collector may yield any Metric it sees fit in its Collect method.
41 // 41 //
42 // This method idempotently sends the same descriptors throughout the 42 // This method idempotently sends the same descriptors throughout the
43 // lifetime of the Collector. 43 // lifetime of the Collector. It may be called concurrently and
44 // therefore must be implemented in a concurrency safe way.
44 // 45 //
45 // If a Collector encounters an error while executing this method, it 46 // If a Collector encounters an error while executing this method, it
46 // must send an invalid descriptor (created with NewInvalidDesc) to 47 // must send an invalid descriptor (created with NewInvalidDesc) to
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
index 29dc8e3..4d7fa97 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
@@ -187,6 +187,7 @@ func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogr
187 desc: desc, 187 desc: desc,
188 upperBounds: opts.Buckets, 188 upperBounds: opts.Buckets,
189 labelPairs: makeLabelPairs(desc, labelValues), 189 labelPairs: makeLabelPairs(desc, labelValues),
190 counts: [2]*histogramCounts{&histogramCounts{}, &histogramCounts{}},
190 } 191 }
191 for i, upperBound := range h.upperBounds { 192 for i, upperBound := range h.upperBounds {
192 if i < len(h.upperBounds)-1 { 193 if i < len(h.upperBounds)-1 {
@@ -223,6 +224,21 @@ type histogramCounts struct {
223} 224}
224 225
225type histogram struct { 226type histogram struct {
227 // countAndHotIdx is a complicated one. For lock-free yet atomic
228 // observations, we need to save the total count of observations again,
229 // combined with the index of the currently-hot counts struct, so that
230 // we can perform the operation on both values atomically. The least
231 // significant bit defines the hot counts struct. The remaining 63 bits
232 // represent the total count of observations. This happens under the
233 // assumption that the 63bit count will never overflow. Rationale: An
234 // observations takes about 30ns. Let's assume it could happen in
235 // 10ns. Overflowing the counter will then take at least (2^63)*10ns,
236 // which is about 3000 years.
237 //
238 // This has to be first in the struct for 64bit alignment. See
239 // http://golang.org/pkg/sync/atomic/#pkg-note-BUG
240 countAndHotIdx uint64
241
226 selfCollector 242 selfCollector
227 desc *Desc 243 desc *Desc
228 writeMtx sync.Mutex // Only used in the Write method. 244 writeMtx sync.Mutex // Only used in the Write method.
@@ -230,23 +246,12 @@ type histogram struct {
230 upperBounds []float64 246 upperBounds []float64
231 247
232 // Two counts, one is "hot" for lock-free observations, the other is 248 // Two counts, one is "hot" for lock-free observations, the other is
233 // "cold" for writing out a dto.Metric. 249 // "cold" for writing out a dto.Metric. It has to be an array of
234 counts [2]histogramCounts 250 // pointers to guarantee 64bit alignment of the histogramCounts, see
235 251 // http://golang.org/pkg/sync/atomic/#pkg-note-BUG.
252 counts [2]*histogramCounts
236 hotIdx int // Index of currently-hot counts. Only used within Write. 253 hotIdx int // Index of currently-hot counts. Only used within Write.
237 254
238 // This is a complicated one. For lock-free yet atomic observations, we
239 // need to save the total count of observations again, combined with the
240 // index of the currently-hot counts struct, so that we can perform the
241 // operation on both values atomically. The least significant bit
242 // defines the hot counts struct. The remaining 63 bits represent the
243 // total count of observations. This happens under the assumption that
244 // the 63bit count will never overflow. Rationale: An observations takes
245 // about 30ns. Let's assume it could happen in 10ns. Overflowing the
246 // counter will then take at least (2^63)*10ns, which is about 3000
247 // years.
248 countAndHotIdx uint64
249
250 labelPairs []*dto.LabelPair 255 labelPairs []*dto.LabelPair
251} 256}
252 257
@@ -270,7 +275,7 @@ func (h *histogram) Observe(v float64) {
270 // 63 bits gets incremented by 1. At the same time, we get the new value 275 // 63 bits gets incremented by 1. At the same time, we get the new value
271 // back, which we can use to find the currently-hot counts. 276 // back, which we can use to find the currently-hot counts.
272 n := atomic.AddUint64(&h.countAndHotIdx, 2) 277 n := atomic.AddUint64(&h.countAndHotIdx, 2)
273 hotCounts := &h.counts[n%2] 278 hotCounts := h.counts[n%2]
274 279
275 if i < len(h.upperBounds) { 280 if i < len(h.upperBounds) {
276 atomic.AddUint64(&hotCounts.buckets[i], 1) 281 atomic.AddUint64(&hotCounts.buckets[i], 1)
@@ -322,13 +327,13 @@ func (h *histogram) Write(out *dto.Metric) error {
322 if h.hotIdx == 0 { 327 if h.hotIdx == 0 {
323 count = atomic.AddUint64(&h.countAndHotIdx, 1) >> 1 328 count = atomic.AddUint64(&h.countAndHotIdx, 1) >> 1
324 h.hotIdx = 1 329 h.hotIdx = 1
325 hotCounts = &h.counts[1] 330 hotCounts = h.counts[1]
326 coldCounts = &h.counts[0] 331 coldCounts = h.counts[0]
327 } else { 332 } else {
328 count = atomic.AddUint64(&h.countAndHotIdx, ^uint64(0)) >> 1 // Decrement. 333 count = atomic.AddUint64(&h.countAndHotIdx, ^uint64(0)) >> 1 // Decrement.
329 h.hotIdx = 0 334 h.hotIdx = 0
330 hotCounts = &h.counts[0] 335 hotCounts = h.counts[0]
331 coldCounts = &h.counts[1] 336 coldCounts = h.counts[1]
332 } 337 }
333 338
334 // Now we have to wait for the now-declared-cold counts to actually cool 339 // Now we have to wait for the now-declared-cold counts to actually cool
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go
index 2c0b908..e422ef3 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go
@@ -107,9 +107,6 @@ type Registerer interface {
107 // Collector, and for providing a Collector that will not cause 107 // Collector, and for providing a Collector that will not cause
108 // inconsistent metrics on collection. (This would lead to scrape 108 // inconsistent metrics on collection. (This would lead to scrape
109 // errors.) 109 // errors.)
110 //
111 // It is in general not safe to register the same Collector multiple
112 // times concurrently.
113 Register(Collector) error 110 Register(Collector) error
114 // MustRegister works like Register but registers any number of 111 // MustRegister works like Register but registers any number of
115 // Collectors and panics upon the first registration that causes an 112 // Collectors and panics upon the first registration that causes an
@@ -273,7 +270,12 @@ func (r *Registry) Register(c Collector) error {
273 close(descChan) 270 close(descChan)
274 }() 271 }()
275 r.mtx.Lock() 272 r.mtx.Lock()
276 defer r.mtx.Unlock() 273 defer func() {
274 // Drain channel in case of premature return to not leak a goroutine.
275 for range descChan {
276 }
277 r.mtx.Unlock()
278 }()
277 // Conduct various tests... 279 // Conduct various tests...
278 for desc := range descChan { 280 for desc := range descChan {
279 281
@@ -785,6 +787,8 @@ func checkMetricConsistency(
785 dtoMetric *dto.Metric, 787 dtoMetric *dto.Metric,
786 metricHashes map[uint64]struct{}, 788 metricHashes map[uint64]struct{},
787) error { 789) error {
790 name := metricFamily.GetName()
791
788 // Type consistency with metric family. 792 // Type consistency with metric family.
789 if metricFamily.GetType() == dto.MetricType_GAUGE && dtoMetric.Gauge == nil || 793 if metricFamily.GetType() == dto.MetricType_GAUGE && dtoMetric.Gauge == nil ||
790 metricFamily.GetType() == dto.MetricType_COUNTER && dtoMetric.Counter == nil || 794 metricFamily.GetType() == dto.MetricType_COUNTER && dtoMetric.Counter == nil ||
@@ -793,33 +797,42 @@ func checkMetricConsistency(
793 metricFamily.GetType() == dto.MetricType_UNTYPED && dtoMetric.Untyped == nil { 797 metricFamily.GetType() == dto.MetricType_UNTYPED && dtoMetric.Untyped == nil {
794 return fmt.Errorf( 798 return fmt.Errorf(
795 "collected metric %q { %s} is not a %s", 799 "collected metric %q { %s} is not a %s",
796 metricFamily.GetName(), dtoMetric, metricFamily.GetType(), 800 name, dtoMetric, metricFamily.GetType(),
797 ) 801 )
798 } 802 }
799 803
804 previousLabelName := ""
800 for _, labelPair := range dtoMetric.GetLabel() { 805 for _, labelPair := range dtoMetric.GetLabel() {
801 if !checkLabelName(labelPair.GetName()) { 806 labelName := labelPair.GetName()
807 if labelName == previousLabelName {
808 return fmt.Errorf(
809 "collected metric %q { %s} has two or more labels with the same name: %s",
810 name, dtoMetric, labelName,
811 )
812 }
813 if !checkLabelName(labelName) {
802 return fmt.Errorf( 814 return fmt.Errorf(
803 "collected metric %q { %s} has a label with an invalid name: %s", 815 "collected metric %q { %s} has a label with an invalid name: %s",
804 metricFamily.GetName(), dtoMetric, labelPair.GetName(), 816 name, dtoMetric, labelName,
805 ) 817 )
806 } 818 }
807 if dtoMetric.Summary != nil && labelPair.GetName() == quantileLabel { 819 if dtoMetric.Summary != nil && labelName == quantileLabel {
808 return fmt.Errorf( 820 return fmt.Errorf(
809 "collected metric %q { %s} must not have an explicit %q label", 821 "collected metric %q { %s} must not have an explicit %q label",
810 metricFamily.GetName(), dtoMetric, quantileLabel, 822 name, dtoMetric, quantileLabel,
811 ) 823 )
812 } 824 }
813 if !utf8.ValidString(labelPair.GetValue()) { 825 if !utf8.ValidString(labelPair.GetValue()) {
814 return fmt.Errorf( 826 return fmt.Errorf(
815 "collected metric %q { %s} has a label named %q whose value is not utf8: %#v", 827 "collected metric %q { %s} has a label named %q whose value is not utf8: %#v",
816 metricFamily.GetName(), dtoMetric, labelPair.GetName(), labelPair.GetValue()) 828 name, dtoMetric, labelName, labelPair.GetValue())
817 } 829 }
830 previousLabelName = labelName
818 } 831 }
819 832
820 // Is the metric unique (i.e. no other metric with the same name and the same labels)? 833 // Is the metric unique (i.e. no other metric with the same name and the same labels)?
821 h := hashNew() 834 h := hashNew()
822 h = hashAdd(h, metricFamily.GetName()) 835 h = hashAdd(h, name)
823 h = hashAddByte(h, separatorByte) 836 h = hashAddByte(h, separatorByte)
824 // Make sure label pairs are sorted. We depend on it for the consistency 837 // Make sure label pairs are sorted. We depend on it for the consistency
825 // check. 838 // check.
@@ -833,7 +846,7 @@ func checkMetricConsistency(
833 if _, exists := metricHashes[h]; exists { 846 if _, exists := metricHashes[h]; exists {
834 return fmt.Errorf( 847 return fmt.Errorf(
835 "collected metric %q { %s} was collected before with the same name and label values", 848 "collected metric %q { %s} was collected before with the same name and label values",
836 metricFamily.GetName(), dtoMetric, 849 name, dtoMetric,
837 ) 850 )
838 } 851 }
839 metricHashes[h] = struct{}{} 852 metricHashes[h] = struct{}{}
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 320bda2..c05d99e 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -115,22 +115,22 @@
115 "revisionTime": "2017-09-01T18:29:50Z" 115 "revisionTime": "2017-09-01T18:29:50Z"
116 }, 116 },
117 { 117 {
118 "checksumSHA1": "lLvg5TpUtFbkyAoh+aI5T/nnpWw=", 118 "checksumSHA1": "frS661rlSEZWE9CezHhnFioQK/I=",
119 "path": "github.com/prometheus/client_golang/prometheus", 119 "path": "github.com/prometheus/client_golang/prometheus",
120 "revision": "e637cec7d9c8990247098639ebc6d43dd34ddd49", 120 "revision": "0a8115f42e037a6e327f9a269a26ff6603fb8472",
121 "revisionTime": "2018-09-17T10:21:22Z" 121 "revisionTime": "2018-10-01T17:40:01Z"
122 }, 122 },
123 { 123 {
124 "checksumSHA1": "UBqhkyjCz47+S19MVTigxJ2VjVQ=", 124 "checksumSHA1": "UBqhkyjCz47+S19MVTigxJ2VjVQ=",
125 "path": "github.com/prometheus/client_golang/prometheus/internal", 125 "path": "github.com/prometheus/client_golang/prometheus/internal",
126 "revision": "e637cec7d9c8990247098639ebc6d43dd34ddd49", 126 "revision": "0a8115f42e037a6e327f9a269a26ff6603fb8472",
127 "revisionTime": "2018-09-17T10:21:22Z" 127 "revisionTime": "2018-10-01T17:40:01Z"
128 }, 128 },
129 { 129 {
130 "checksumSHA1": "d5BiEvD8MrgpWQ6PQJUvawJsMak=", 130 "checksumSHA1": "d5BiEvD8MrgpWQ6PQJUvawJsMak=",
131 "path": "github.com/prometheus/client_golang/prometheus/promhttp", 131 "path": "github.com/prometheus/client_golang/prometheus/promhttp",
132 "revision": "e637cec7d9c8990247098639ebc6d43dd34ddd49", 132 "revision": "0a8115f42e037a6e327f9a269a26ff6603fb8472",
133 "revisionTime": "2018-09-17T10:21:22Z" 133 "revisionTime": "2018-10-01T17:40:01Z"
134 }, 134 },
135 { 135 {
136 "checksumSHA1": "DvwvOlPNAgRntBzt3b3OSRMS2N4=", 136 "checksumSHA1": "DvwvOlPNAgRntBzt3b3OSRMS2N4=",