From cf9b2a8c789259dfdd4de71d65abff627b1046c0 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 13 Sep 2018 17:43:05 +0200 Subject: [PATCH] Rename WrapWith... to WrapRegistererWith... Signed-off-by: beorn7 --- prometheus/example_clustermanager_test.go | 2 +- prometheus/wrap.go | 35 ++++++++++++----------- prometheus/wrap_test.go | 6 ++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/prometheus/example_clustermanager_test.go b/prometheus/example_clustermanager_test.go index e398cf2..9a5a4b8 100644 --- a/prometheus/example_clustermanager_test.go +++ b/prometheus/example_clustermanager_test.go @@ -111,7 +111,7 @@ func NewClusterManager(zone string, reg prometheus.Registerer) *ClusterManager { Zone: zone, } cc := ClusterManagerCollector{ClusterManager: c} - prometheus.WrapWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc) + prometheus.WrapRegistererWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc) return c } diff --git a/prometheus/wrap.go b/prometheus/wrap.go index 650186e..b967fc0 100644 --- a/prometheus/wrap.go +++ b/prometheus/wrap.go @@ -22,32 +22,33 @@ import ( dto "github.com/prometheus/client_model/go" ) -// WrapWith returns a Registerer wrapping the provided Registerer. Collectors -// registered with the returned Registerer will be registered with the wrapped -// Registerer in a modified way. The modified Collector adds the provided Labels -// to all Metrics it collects (as ConstLabels). The Metrics collected by the -// unmodified Collector must not duplicate any of those labels. +// WrapRegistererWith returns a Registerer wrapping the provided +// Registerer. Collectors registered with the returned Registerer will be +// registered with the wrapped Registerer in a modified way. The modified +// Collector adds the provided Labels to all Metrics it collects (as +// ConstLabels). The Metrics collected by the unmodified Collector must not +// duplicate any of those labels. // -// WrapWith provides a way to add fixed labels to a subset of Collectors. It -// should not be used to add fixed labels to all metrics exposed. +// WrapRegistererWith provides a way to add fixed labels to a subset of +// Collectors. It should not be used to add fixed labels to all metrics exposed. // -// The Collector example demonstrates a use of WrapWith. -func WrapWith(labels Labels, reg Registerer) Registerer { +// The Collector example demonstrates a use of WrapRegistererWith. +func WrapRegistererWith(labels Labels, reg Registerer) Registerer { return &wrappingRegisterer{ wrappedRegisterer: reg, labels: labels, } } -// WrapWithPrefix returns a Registerer wrapping the provided Registerer. Collectors -// registered with the returned Registerer will be registered with the wrapped -// Registerer in a modified way. The modified Collector adds the provided prefix -// to the name of all Metrics it collects. +// WrapRegistererWithPrefix returns a Registerer wrapping the provided +// Registerer. Collectors registered with the returned Registerer will be +// registered with the wrapped Registerer in a modified way. The modified +// Collector adds the provided prefix to the name of all Metrics it collects. // -// WrapWithPrefix is useful to have one place to prefix all metrics of a -// sub-system. To make this work, register metrics of the sub-system with the -// wrapping Registerer returned by WrapWithPrefix. -func WrapWithPrefix(prefix string, reg Registerer) Registerer { +// WrapRegistererWithPrefix is useful to have one place to prefix all metrics of +// a sub-system. To make this work, register metrics of the sub-system with the +// wrapping Registerer returned by WrapRegistererWithPrefix. +func WrapRegistererWithPrefix(prefix string, reg Registerer) Registerer { return &wrappingRegisterer{ wrappedRegisterer: reg, prefix: prefix, diff --git a/prometheus/wrap_test.go b/prometheus/wrap_test.go index 4c1dc2e..bed103e 100644 --- a/prometheus/wrap_test.go +++ b/prometheus/wrap_test.go @@ -275,9 +275,9 @@ func TestWrap(t *testing.T) { t.Fatal("error registering with unwrapped registry:", err) } } - preReg := WrapWithPrefix(s.prefix, reg) - lReg := WrapWith(s.labels, preReg) - l2Reg := WrapWith(s.labels2, preReg) + preReg := WrapRegistererWithPrefix(s.prefix, reg) + lReg := WrapRegistererWith(s.labels, preReg) + l2Reg := WrapRegistererWith(s.labels2, preReg) for i, tr := range s.toRegister { var err error if i%2 != 0 && len(s.labels2) != 0 {