Browse Source

Update go-metrics to match swarmkit's dependency

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Aaron Lehmann 8 năm trước cách đây
mục cha
commit
0a377b5f56

+ 1 - 1
vendor.conf

@@ -132,6 +132,6 @@ github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
 github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty
 github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty
 
 
 # metrics
 # metrics
-github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87
+github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18
 
 
 github.com/opencontainers/selinux v1.0.0-rc1
 github.com/opencontainers/selinux v1.0.0-rc1

+ 12 - 6
vendor/github.com/docker/go-metrics/namespace.go

@@ -66,7 +66,7 @@ func (n *Namespace) newCounterOpts(name, help string) prometheus.CounterOpts {
 	return prometheus.CounterOpts{
 	return prometheus.CounterOpts{
 		Namespace:   n.name,
 		Namespace:   n.name,
 		Subsystem:   n.subsystem,
 		Subsystem:   n.subsystem,
-		Name:        fmt.Sprintf("%s_%s", name, Total),
+		Name:        makeName(name, Total),
 		Help:        help,
 		Help:        help,
 		ConstLabels: prometheus.Labels(n.labels),
 		ConstLabels: prometheus.Labels(n.labels),
 	}
 	}
@@ -92,7 +92,7 @@ func (n *Namespace) newTimerOpts(name, help string) prometheus.HistogramOpts {
 	return prometheus.HistogramOpts{
 	return prometheus.HistogramOpts{
 		Namespace:   n.name,
 		Namespace:   n.name,
 		Subsystem:   n.subsystem,
 		Subsystem:   n.subsystem,
-		Name:        fmt.Sprintf("%s_%s", name, Seconds),
+		Name:        makeName(name, Seconds),
 		Help:        help,
 		Help:        help,
 		ConstLabels: prometheus.Labels(n.labels),
 		ConstLabels: prometheus.Labels(n.labels),
 	}
 	}
@@ -118,7 +118,7 @@ func (n *Namespace) newGaugeOpts(name, help string, unit Unit) prometheus.GaugeO
 	return prometheus.GaugeOpts{
 	return prometheus.GaugeOpts{
 		Namespace:   n.name,
 		Namespace:   n.name,
 		Subsystem:   n.subsystem,
 		Subsystem:   n.subsystem,
-		Name:        fmt.Sprintf("%s_%s", name, unit),
+		Name:        makeName(name, unit),
 		Help:        help,
 		Help:        help,
 		ConstLabels: prometheus.Labels(n.labels),
 		ConstLabels: prometheus.Labels(n.labels),
 	}
 	}
@@ -149,9 +149,7 @@ func (n *Namespace) Add(collector prometheus.Collector) {
 }
 }
 
 
 func (n *Namespace) NewDesc(name, help string, unit Unit, labels ...string) *prometheus.Desc {
 func (n *Namespace) NewDesc(name, help string, unit Unit, labels ...string) *prometheus.Desc {
-	if string(unit) != "" {
-		name = fmt.Sprintf("%s_%s", name, unit)
-	}
+	name = makeName(name, unit)
 	namespace := n.name
 	namespace := n.name
 	if n.subsystem != "" {
 	if n.subsystem != "" {
 		namespace = fmt.Sprintf("%s_%s", namespace, n.subsystem)
 		namespace = fmt.Sprintf("%s_%s", namespace, n.subsystem)
@@ -173,3 +171,11 @@ func mergeLabels(lbs ...Labels) Labels {
 
 
 	return merged
 	return merged
 }
 }
+
+func makeName(name string, unit Unit) string {
+	if unit == "" {
+		return name
+	}
+
+	return fmt.Sprintf("%s_%s", name, unit)
+}