mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
add logging to the scheduler
This commit is contained in:
parent
16eeaae3ad
commit
00bd99b60e
1 changed files with 13 additions and 5 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/DataDog/datadog-go/statsd"
|
"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)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
enqueued := 0
|
var (
|
||||||
skipped := 0
|
enqueued int64 = 0
|
||||||
|
skipped int64 = 0
|
||||||
|
)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
tags := []string{"queue:notifications"}
|
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))
|
logger.Error("failed to check for locked accounts", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
skipped += len(batch) - len(unlocked)
|
atomic.AddInt64(&skipped, int64(len(batch)-len(unlocked)))
|
||||||
enqueued += len(unlocked)
|
atomic.AddInt64(&enqueued, int64(len(unlocked)))
|
||||||
|
|
||||||
if len(unlocked) == 0 {
|
if len(unlocked) == 0 {
|
||||||
return
|
return
|
||||||
|
@ -517,7 +520,12 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli
|
||||||
}
|
}
|
||||||
wg.Wait()
|
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
|
type Int64Slice []int64
|
||||||
|
|
Loading…
Reference in a new issue