From 00bd99b60e917d385ed2847adae8497de90c6f40 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Mon, 31 Oct 2022 15:49:27 -0400 Subject: [PATCH] add logging to the scheduler --- internal/cmd/scheduler.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 0ad7019..6f60bcc 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -8,6 +8,7 @@ import ( _ "net/http/pprof" "strconv" "sync" + "sync/atomic" "time" "github.com/DataDog/datadog-go/statsd" @@ -471,8 +472,10 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli ids = append(ids, id) } - enqueued := 0 - skipped := 0 + var ( + enqueued int64 = 0 + skipped int64 = 0 + ) defer func() { tags := []string{"queue:notifications"} @@ -503,8 +506,8 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli logger.Error("failed to check for locked accounts", zap.Error(err)) } - skipped += len(batch) - len(unlocked) - enqueued += len(unlocked) + atomic.AddInt64(&skipped, int64(len(batch)-len(unlocked))) + atomic.AddInt64(&enqueued, int64(len(unlocked))) if len(unlocked) == 0 { return @@ -517,7 +520,12 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli } wg.Wait() - logger.Debug("done enqueueing account batch", zap.Int("count", enqueued), zap.Int("skipped", skipped), zap.Time("start", now)) + logger.Info("enqueued account batch", + zap.Int64("count", enqueued), + zap.Int64("skipped", skipped), + zap.Time("start", now), + zap.Int64("duration", time.Since(now).Milliseconds()), + ) } type Int64Slice []int64