diff options
author | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-01 10:34:28 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@rgdd.se> | 2023-04-01 10:34:28 +0200 |
commit | 897970aa3fc100e0ed5fd6ddcea6bd9867c029d3 (patch) | |
tree | 84b2d879843792860d50ad88b363d72f19dadcfd | |
parent | 9b84f21daf8196c883ede8f50c99c479b3ef0cbb (diff) |
Add more metrics
Number of connected / onion location / connection attempts.
-rw-r--r-- | .main.go.swp | bin | 0 -> 20480 bytes | |||
-rw-r--r-- | main.go | 12 |
2 files changed, 8 insertions, 4 deletions
diff --git a/.main.go.swp b/.main.go.swp Binary files differnew file mode 100644 index 0000000..36e0a39 --- /dev/null +++ b/.main.go.swp @@ -146,10 +146,9 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna numConnect := 0 numOnions := 0 numAll := 0 - output := func() { - log.Printf("SUMMARY: %d/%d connected, %d sites configured Onion-Location\n", numConnect, numAll, numOnions) + output := func(prefix string) { + log.Printf("%s: %d/%d connected, %d sites configured Onion-Location\n", prefix, numConnect, numAll, numOnions) } - handleAnswer := func(a qna.Answer) { numAll += 1 if !a.OK { @@ -163,7 +162,10 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna } } - defer output() + metrics := time.NewTicker(opts.MetricsInterval) + defer metrics.Stop() + + defer output("SUMMARY") for { select { case <-ctx.Done(): @@ -178,6 +180,8 @@ func workAggregator(ctx context.Context, opts options.Options, answerCh chan qna } case a := <-answerCh: handleAnswer(a) + case <-metrics.C: + output("INFO") } } } |