mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
metrics: apply gosimple rules
This commit is contained in:
parent
c14cd857b8
commit
aaef540a50
2 changed files with 5 additions and 8 deletions
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// a regexp for extracting the unit from time.Duration.String
|
// a regexp for extracting the unit from time.Duration.String
|
||||||
var unitRegexp = regexp.MustCompile("[^\\d]+$")
|
var unitRegexp = regexp.MustCompile(`[^\\d]+$`)
|
||||||
|
|
||||||
// a helper that turns a time.Duration into librato display attributes for timer metrics
|
// a helper that turns a time.Duration into librato display attributes for timer metrics
|
||||||
func translateTimerAttributes(d time.Duration) (attrs map[string]interface{}) {
|
func translateTimerAttributes(d time.Duration) (attrs map[string]interface{}) {
|
||||||
|
|
@ -116,7 +116,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
|
||||||
snapshot.Gauges = append(snapshot.Gauges, measurement)
|
snapshot.Gauges = append(snapshot.Gauges, measurement)
|
||||||
case metrics.Histogram:
|
case metrics.Histogram:
|
||||||
if m.Count() > 0 {
|
if m.Count() > 0 {
|
||||||
gauges := make([]Measurement, histogramGaugeCount, histogramGaugeCount)
|
gauges := make([]Measurement, histogramGaugeCount)
|
||||||
s := m.Sample()
|
s := m.Sample()
|
||||||
measurement[Name] = fmt.Sprintf("%s.%s", name, "hist")
|
measurement[Name] = fmt.Sprintf("%s.%s", name, "hist")
|
||||||
measurement[Count] = uint64(s.Count())
|
measurement[Count] = uint64(s.Count())
|
||||||
|
|
@ -176,7 +176,7 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
|
||||||
snapshot.Counters = append(snapshot.Counters, measurement)
|
snapshot.Counters = append(snapshot.Counters, measurement)
|
||||||
if m.Count() > 0 {
|
if m.Count() > 0 {
|
||||||
libratoName := fmt.Sprintf("%s.%s", name, "timer.mean")
|
libratoName := fmt.Sprintf("%s.%s", name, "timer.mean")
|
||||||
gauges := make([]Measurement, histogramGaugeCount, histogramGaugeCount)
|
gauges := make([]Measurement, histogramGaugeCount)
|
||||||
gauges[0] = Measurement{
|
gauges[0] = Measurement{
|
||||||
Name: libratoName,
|
Name: libratoName,
|
||||||
Count: uint64(m.Count()),
|
Count: uint64(m.Count()),
|
||||||
|
|
|
||||||
|
|
@ -247,13 +247,10 @@ var arbiter = meterArbiter{ticker: time.NewTicker(5e9), meters: make(map[*Standa
|
||||||
|
|
||||||
// Ticks meters on the scheduled interval
|
// Ticks meters on the scheduled interval
|
||||||
func (ma *meterArbiter) tick() {
|
func (ma *meterArbiter) tick() {
|
||||||
for {
|
for range ma.ticker.C {
|
||||||
select {
|
|
||||||
case <-ma.ticker.C:
|
|
||||||
ma.tickMeters()
|
ma.tickMeters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (ma *meterArbiter) tickMeters() {
|
func (ma *meterArbiter) tickMeters() {
|
||||||
ma.RLock()
|
ma.RLock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue