Skip to content

Commit

Permalink
Use time.Tick everywhere else we should, too
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrowley committed Aug 3, 2014
1 parent 3fbdc8d commit 3331190
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ var (
// Capture new values for the Go garbage collector statistics exported in
// debug.GCStats. This is designed to be called as a goroutine.
func CaptureDebugGCStats(r Registry, d time.Duration) {
for {
for _ = range time.Tick(d) {
CaptureDebugGCStatsOnce(r)
time.Sleep(d)
}
}

Expand Down
3 changes: 1 addition & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Output each metric in the given registry periodically using the given
// logger.
func Log(r Registry, d time.Duration, l *log.Logger) {
for {
for _ = range time.Tick(d) {
r.Each(func(name string, i interface{}) {
switch metric := i.(type) {
case Counter:
Expand Down Expand Up @@ -66,6 +66,5 @@ func Log(r Registry, d time.Duration, l *log.Logger) {
l.Printf(" mean rate: %12.2f\n", t.RateMean())
}
})
time.Sleep(d)
}
}
3 changes: 1 addition & 2 deletions runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ var (
// Capture new values for the Go runtime statistics exported in
// runtime.MemStats. This is designed to be called as a goroutine.
func CaptureRuntimeMemStats(r Registry, d time.Duration) {
for {
for _ = range time.Tick(d) {
CaptureRuntimeMemStatsOnce(r)
time.Sleep(d)
}
}

Expand Down
3 changes: 1 addition & 2 deletions syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// Output each metric in the given registry to syslog periodically using
// the given syslogger.
func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
for {
for _ = range time.Tick(d) {
r.Each(func(name string, i interface{}) {
switch metric := i.(type) {
case Counter:
Expand Down Expand Up @@ -74,6 +74,5 @@ func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
))
}
})
time.Sleep(d)
}
}
3 changes: 1 addition & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
// Write sorts writes each metric in the given registry periodically to the
// given io.Writer.
func Write(r Registry, d time.Duration, w io.Writer) {
for {
for _ = range time.Tick(d) {
WriteOnce(r, w)
time.Sleep(d)
}
}

Expand Down

0 comments on commit 3331190

Please sign in to comment.