forked from mirror/client_golang
Rename WrapWith... to WrapRegistererWith...
Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
837c7cb1f4
commit
cf9b2a8c78
|
@ -111,7 +111,7 @@ func NewClusterManager(zone string, reg prometheus.Registerer) *ClusterManager {
|
||||||
Zone: zone,
|
Zone: zone,
|
||||||
}
|
}
|
||||||
cc := ClusterManagerCollector{ClusterManager: c}
|
cc := ClusterManagerCollector{ClusterManager: c}
|
||||||
prometheus.WrapWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc)
|
prometheus.WrapRegistererWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc)
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,32 +22,33 @@ import (
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WrapWith returns a Registerer wrapping the provided Registerer. Collectors
|
// WrapRegistererWith returns a Registerer wrapping the provided
|
||||||
// registered with the returned Registerer will be registered with the wrapped
|
// Registerer. Collectors registered with the returned Registerer will be
|
||||||
// Registerer in a modified way. The modified Collector adds the provided Labels
|
// registered with the wrapped Registerer in a modified way. The modified
|
||||||
// to all Metrics it collects (as ConstLabels). The Metrics collected by the
|
// Collector adds the provided Labels to all Metrics it collects (as
|
||||||
// unmodified Collector must not duplicate any of those labels.
|
// 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
|
// WrapRegistererWith provides a way to add fixed labels to a subset of
|
||||||
// should not be used to add fixed labels to all metrics exposed.
|
// Collectors. It should not be used to add fixed labels to all metrics exposed.
|
||||||
//
|
//
|
||||||
// The Collector example demonstrates a use of WrapWith.
|
// The Collector example demonstrates a use of WrapRegistererWith.
|
||||||
func WrapWith(labels Labels, reg Registerer) Registerer {
|
func WrapRegistererWith(labels Labels, reg Registerer) Registerer {
|
||||||
return &wrappingRegisterer{
|
return &wrappingRegisterer{
|
||||||
wrappedRegisterer: reg,
|
wrappedRegisterer: reg,
|
||||||
labels: labels,
|
labels: labels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WrapWithPrefix returns a Registerer wrapping the provided Registerer. Collectors
|
// WrapRegistererWithPrefix returns a Registerer wrapping the provided
|
||||||
// registered with the returned Registerer will be registered with the wrapped
|
// Registerer. Collectors registered with the returned Registerer will be
|
||||||
// Registerer in a modified way. The modified Collector adds the provided prefix
|
// registered with the wrapped Registerer in a modified way. The modified
|
||||||
// to the name of all Metrics it collects.
|
// 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
|
// WrapRegistererWithPrefix is useful to have one place to prefix all metrics of
|
||||||
// sub-system. To make this work, register metrics of the sub-system with the
|
// a sub-system. To make this work, register metrics of the sub-system with the
|
||||||
// wrapping Registerer returned by WrapWithPrefix.
|
// wrapping Registerer returned by WrapRegistererWithPrefix.
|
||||||
func WrapWithPrefix(prefix string, reg Registerer) Registerer {
|
func WrapRegistererWithPrefix(prefix string, reg Registerer) Registerer {
|
||||||
return &wrappingRegisterer{
|
return &wrappingRegisterer{
|
||||||
wrappedRegisterer: reg,
|
wrappedRegisterer: reg,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
|
|
|
@ -275,9 +275,9 @@ func TestWrap(t *testing.T) {
|
||||||
t.Fatal("error registering with unwrapped registry:", err)
|
t.Fatal("error registering with unwrapped registry:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preReg := WrapWithPrefix(s.prefix, reg)
|
preReg := WrapRegistererWithPrefix(s.prefix, reg)
|
||||||
lReg := WrapWith(s.labels, preReg)
|
lReg := WrapRegistererWith(s.labels, preReg)
|
||||||
l2Reg := WrapWith(s.labels2, preReg)
|
l2Reg := WrapRegistererWith(s.labels2, preReg)
|
||||||
for i, tr := range s.toRegister {
|
for i, tr := range s.toRegister {
|
||||||
var err error
|
var err error
|
||||||
if i%2 != 0 && len(s.labels2) != 0 {
|
if i%2 != 0 && len(s.labels2) != 0 {
|
||||||
|
|
Loading…
Reference in New Issue