Skip to content

Commit

Permalink
metrics: fix issues reported by staticcheck (ethereum#20365)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan authored and JukLee0ira committed Dec 22, 2024
1 parent 115f67d commit 04fbd23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions metrics/librato/librato.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ func Librato(r metrics.Registry, d time.Duration, e string, t string, s string,

func (re *Reporter) Run() {
log.Printf("WARNING: This client has been DEPRECATED! It has been moved to https://github.com/mihasya/go-metrics-librato and will be removed from rcrowley/go-metrics on August 5th 2015")
ticker := time.Tick(re.Interval)
ticker := time.NewTicker(re.Interval)
defer ticker.Stop()
metricsApi := &LibratoClient{re.Email, re.Token}
for now := range ticker {
for now := range ticker.C {
var metrics Batch
var err error
if metrics, err = re.BuildRequest(now, re.Registry); err != nil {
Expand Down
13 changes: 9 additions & 4 deletions metrics/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,18 @@ func TestChildPrefixedRegistryOfChildRegister(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
r2.Register("baz", NewCounter())
err = r2.Register("baz", NewCounter())
if err != nil {
t.Fatal(err.Error())
}
c := NewCounter()
Register("bars", c)

i := 0
r2.Each(func(name string, m interface{}) {
i++
if name != "prefix.prefix2.baz" {
//t.Fatal(name)
t.Fatal(name)
}
})
if i != 1 {
Expand All @@ -293,13 +296,15 @@ func TestWalkRegistries(t *testing.T) {
if err != nil {
t.Fatal(err.Error())
}
r2.Register("baz", NewCounter())
err = r2.Register("baz", NewCounter())
if err != nil {
t.Fatal(err.Error())
}
c := NewCounter()
Register("bars", c)

_, prefix := findPrefix(r2, "")
if prefix != "prefix.prefix2." {
t.Fatal(prefix)
}

}
5 changes: 1 addition & 4 deletions metrics/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ func NewTimer() Timer {
}

// NilTimer is a no-op Timer.
type NilTimer struct {
h Histogram
m Meter
}
type NilTimer struct{}

// Count is a no-op.
func (NilTimer) Count() int64 { return 0 }
Expand Down

0 comments on commit 04fbd23

Please sign in to comment.