From 52bd32914a6184ee4d403f8418eb0546074ac5bb Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Sat, 18 Mar 2023 13:48:41 +0100 Subject: Print metrics based on flag duration to stderr --- utils_housekeep.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'utils_housekeep.go') diff --git a/utils_housekeep.go b/utils_housekeep.go index 670a95b..d34292f 100644 --- a/utils_housekeep.go +++ b/utils_housekeep.go @@ -3,7 +3,6 @@ package main import ( "context" "fmt" - logger "log" "os" "os/signal" "syscall" @@ -39,7 +38,7 @@ func (m *metrics) update(other metrics) { m.avg = float64(m.NumEntries) / float64((other.Timestamp - m.Timestamp)) } -func handleMetrics(ctx context.Context, metricsCh chan metrics, logs []metadata.Log) { +func handleMetrics(ctx context.Context, opts options, logs []metadata.Log, metricsCh chan metrics) { sum := make(map[string]metrics) for _, log := range logs { sum[*log.Description] = metrics{ @@ -48,7 +47,7 @@ func handleMetrics(ctx context.Context, metricsCh chan metrics, logs []metadata. } } - ticker := time.NewTicker(15 * time.Second) + ticker := time.NewTicker(opts.MetricsInterval) defer ticker.Stop() for { select { @@ -62,7 +61,7 @@ func handleMetrics(ctx context.Context, metricsCh chan metrics, logs []metadata. for _, log := range logs { output += sum[*log.Description].String() } - logger.Printf("INFO: periodic status update\n\n%s\n\n", output) + fmt.Fprintf(os.Stderr, "INFO: periodic status update\n\n%s\n\n", output) } } } -- cgit v1.2.3