|
|
@@ -8,18 +8,21 @@ type Logger interface {
|
|
|
Printf(format string, v ...interface{})
|
|
|
}
|
|
|
|
|
|
+// Log outputs each metric in the given registry periodically using the given logger.
|
|
|
func Log(r Registry, freq time.Duration, l Logger) {
|
|
|
LogScaled(r, freq, time.Nanosecond, l)
|
|
|
}
|
|
|
|
|
|
+// LogOnCue outputs each metric in the given registry on demand through the channel
|
|
|
+// using the given logger
|
|
|
func LogOnCue(r Registry, ch chan interface{}, l Logger) {
|
|
|
LogScaledOnCue(r, ch, time.Nanosecond, l)
|
|
|
}
|
|
|
|
|
|
-// Output each metric in the given registry periodically using the given
|
|
|
+// LogScaled outputs each metric in the given registry periodically using the given
|
|
|
// logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos.
|
|
|
func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger) {
|
|
|
- ch := make(chan struct{}, 1)
|
|
|
+ ch := make(chan interface{}, 1)
|
|
|
go func() {
|
|
|
for range time.Tick(freq) {
|
|
|
ch <- struct{}{}
|
|
|
@@ -28,8 +31,9 @@ func LogScaled(r Registry, freq time.Duration, scale time.Duration, l Logger) {
|
|
|
LogScaledOnCue(r, ch, scale, l)
|
|
|
}
|
|
|
|
|
|
-// Output each metric in the given registry on demand through the channel using the given
|
|
|
-// logger. Print timings in `scale` units (eg time.Millisecond) rather than nanos.
|
|
|
+// LogScaledOnCue outputs each metric in the given registry on demand through the channel
|
|
|
+// using the given logger. Print timings in `scale` units (eg time.Millisecond) rather
|
|
|
+// than nanos.
|
|
|
func LogScaledOnCue(r Registry, ch chan interface{}, scale time.Duration, l Logger) {
|
|
|
du := float64(scale)
|
|
|
duSuffix := scale.String()[1:]
|