Package: docker.io / 18.09.5+dfsg1-1

go-metrics_prometheus-fix_Observer.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Origin: upstream, https://github.com/docker/go-metrics/commit/db152003892af64a8a892e1ee49edf8b6580a657.patch
Forarded: not-needed
Description: fixes FTBFS
 vendor/github.com/docker/go-metrics/timer.go:39:17:
 cannot use lt.m.WithLabelValues(labels...) (type prometheus.Observer) as type prometheus.Histogram in field value:
        prometheus.Observer does not implement prometheus.Histogram (missing Collect method)

--- a/go-metrics/timer.go
+++ b/go-metrics/timer.go
@@ -47,9 +47,9 @@
 	lt.m.Collect(c)
 }
 
 type timer struct {
-	m prometheus.Histogram
+	m prometheus.Observer
 }
 
 func (t *timer) Update(duration time.Duration) {
 	t.m.Observe(duration.Seconds())
@@ -59,10 +59,15 @@
 	t.m.Observe(time.Since(since).Seconds())
 }
 
 func (t *timer) Describe(c chan<- *prometheus.Desc) {
-	t.m.Describe(c)
+	c <- t.m.(prometheus.Metric).Desc()
 }
 
 func (t *timer) Collect(c chan<- prometheus.Metric) {
-	t.m.Collect(c)
+	// Are there any observers that don't implement Collector? It is really
+	// unclear what the point of the upstream change was, but we'll let this
+	// panic if we get an observer that doesn't implement collector. In this
+	// case, we should almost always see metricVec objects, so this should
+	// never panic.
+	t.m.(prometheus.Collector).Collect(c)
 }