diff --git a/server/status/monitor.go b/server/status/monitor.go index 1cd808cd6270..7bf86f7d5025 100644 --- a/server/status/monitor.go +++ b/server/status/monitor.go @@ -53,9 +53,9 @@ type NodeStatusMonitor struct { func NewNodeStatusMonitor(metaRegistry *metric.Registry) *NodeStatusMonitor { registry := metric.NewRegistry() return &NodeStatusMonitor{ - latency: registry.Latency("latency%s"), - rateSuccess: registry.Rates("exec.rate.success%s"), - rateError: registry.Rates("exec.rate.error%s"), + latency: registry.Latency("latency"), + rateSuccess: registry.Rates("exec.rate.success"), + rateError: registry.Rates("exec.rate.error"), numSuccess: registry.Counter("exec.num.success"), numError: registry.Counter("exec.num.error"), diff --git a/sql/executor.go b/sql/executor.go index a16b53d09805..9d3137ee498f 100644 --- a/sql/executor.go +++ b/sql/executor.go @@ -86,7 +86,7 @@ func newExecutor(db client.DB, gossip *gossip.Gossip, leaseMgr *LeaseManager, me reCache: parser.NewRegexpCache(512), leaseMgr: leaseMgr, - latency: metaRegistry.Latency("sql.latency%s"), + latency: metaRegistry.Latency("sql.latency"), } exec.systemConfigCond = sync.NewCond(&exec.systemConfigMu) diff --git a/util/metric/registry.go b/util/metric/registry.go index a49c5120b527..435d72c755a8 100644 --- a/util/metric/registry.go +++ b/util/metric/registry.go @@ -93,13 +93,12 @@ func (r *Registry) Histogram(name string, duration time.Duration, unit Unit, max // Latency is a convenience function which registers histograms with // suitable defaults for latency tracking on millisecond to minute time scales. -// The generated names of the metric can be controlled via the given format -// string. -func (r *Registry) Latency(format string) Histograms { +// The generated names of the metric will begin with the given prefix. +func (r *Registry) Latency(prefix string) Histograms { windows := []timeScale{scale1M, scale10M, scale1H} hs := make([]*Histogram, 0, 3) for _, w := range windows { - h := r.Histogram(fmt.Sprintf(format, w.name), w.d, UnitMs, MaxMinute, 2) + h := r.Histogram(prefix+w.name, w.d, UnitMs, MaxMinute, 2) hs = append(hs, h) } return hs @@ -137,14 +136,13 @@ func (r *Registry) Rate(name string, timescale time.Duration) *Rate { return e } -// Rates returns a slice of EWMAs with the given format string and +// Rates returns a slice of EWMAs prefixed with the given name and // various "standard" timescales. -func (r *Registry) Rates(format string) Rates { +func (r *Registry) Rates(prefix string) Rates { scales := []timeScale{scale1M, scale10M, scale1H} es := make([]*Rate, 0, len(scales)) for _, scale := range scales { - es = append(es, r.Rate(fmt.Sprintf(format, scale.name), - scale.d)) + es = append(es, r.Rate(prefix+scale.name, scale.d)) } return es }