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,
|
||||
}
|
||||
cc := ClusterManagerCollector{ClusterManager: c}
|
||||
prometheus.WrapWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc)
|
||||
prometheus.WrapRegistererWith(prometheus.Labels{"zone": zone}, reg).MustRegister(cc)
|
||||
return c
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue