Update dependencies (#5518)

This commit is contained in:
hongming
2023-02-12 23:09:20 +08:00
committed by GitHub
parent d3b35fb2da
commit a979342f56
1486 changed files with 126660 additions and 71128 deletions

View File

@@ -8,17 +8,37 @@ 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)
}
// Output each metric in the given registry periodically using the given
// 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)
}
// 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 interface{})
go func(channel chan interface{}) {
for _ = range time.Tick(freq) {
channel <- struct{}{}
}
}(ch)
LogScaledOnCue(r, ch, scale, l)
}
// 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:]
for _ = range time.Tick(freq) {
for _ = range ch {
r.Each(func(name string, i interface{}) {
switch metric := i.(type) {
case Counter: