Skip to content

Commit

Permalink
[tbs] remove some format strings
Browse files Browse the repository at this point in the history
  • Loading branch information
tbg committed Dec 25, 2015
1 parent c80f26b commit 6616f67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions server/status/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Expand Down
2 changes: 1 addition & 1 deletion sql/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 6 additions & 8 deletions util/metric/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit 6616f67

Please sign in to comment.