From 73273d4d5a466169d2dd11aa8b7086a728c0de4c Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Fri, 12 May 2017 17:40:46 -0700 Subject: [PATCH] Update go-metrics to match swarmkit's dependency Signed-off-by: Aaron Lehmann Upstream-commit: 0a377b5f56181c59f68c21cf4c5507218f0109ac Component: engine --- components/engine/vendor.conf | 2 +- .../github.com/docker/go-metrics/namespace.go | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/engine/vendor.conf b/components/engine/vendor.conf index 4b10a53118..a6bd5cabcc 100644 --- a/components/engine/vendor.conf +++ b/components/engine/vendor.conf @@ -132,6 +132,6 @@ github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty # metrics -github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87 +github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18 github.com/opencontainers/selinux v1.0.0-rc1 diff --git a/components/engine/vendor/github.com/docker/go-metrics/namespace.go b/components/engine/vendor/github.com/docker/go-metrics/namespace.go index 27dab786df..7734c29459 100644 --- a/components/engine/vendor/github.com/docker/go-metrics/namespace.go +++ b/components/engine/vendor/github.com/docker/go-metrics/namespace.go @@ -66,7 +66,7 @@ func (n *Namespace) newCounterOpts(name, help string) prometheus.CounterOpts { return prometheus.CounterOpts{ Namespace: n.name, Subsystem: n.subsystem, - Name: fmt.Sprintf("%s_%s", name, Total), + Name: makeName(name, Total), Help: help, ConstLabels: prometheus.Labels(n.labels), } @@ -92,7 +92,7 @@ func (n *Namespace) newTimerOpts(name, help string) prometheus.HistogramOpts { return prometheus.HistogramOpts{ Namespace: n.name, Subsystem: n.subsystem, - Name: fmt.Sprintf("%s_%s", name, Seconds), + Name: makeName(name, Seconds), Help: help, ConstLabels: prometheus.Labels(n.labels), } @@ -118,7 +118,7 @@ func (n *Namespace) newGaugeOpts(name, help string, unit Unit) prometheus.GaugeO return prometheus.GaugeOpts{ Namespace: n.name, Subsystem: n.subsystem, - Name: fmt.Sprintf("%s_%s", name, unit), + Name: makeName(name, unit), Help: help, 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 { - if string(unit) != "" { - name = fmt.Sprintf("%s_%s", name, unit) - } + name = makeName(name, unit) namespace := n.name if n.subsystem != "" { namespace = fmt.Sprintf("%s_%s", namespace, n.subsystem) @@ -173,3 +171,11 @@ func mergeLabels(lbs ...Labels) Labels { return merged } + +func makeName(name string, unit Unit) string { + if unit == "" { + return name + } + + return fmt.Sprintf("%s_%s", name, unit) +}