Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only log hearbeat if status changed #529

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,25 @@ func (p *producer) dispatchWork(workCtx context.Context, count int, fetchResultC
func (p *producer) heartbeatLogLoop(ctx context.Context) {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
type jobCount struct {
ran uint64
active int
}
var prevCount jobCount
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
p.Logger.InfoContext(ctx, p.Name+": Heartbeat",
slog.Uint64("num_completed_jobs", p.numJobsRan.Load()),
slog.Int("num_jobs_running", int(p.numJobsActive.Load())),
slog.String("queue", p.config.Queue),
)
curCount := jobCount{ran: p.numJobsRan.Load(), active: int(p.numJobsActive.Load())}
if curCount != prevCount {
p.Logger.InfoContext(ctx, p.Name+": Producer job counts",
slog.Uint64("num_completed_jobs", curCount.ran),
slog.Int("num_jobs_running", curCount.active),
slog.String("queue", p.config.Queue),
)
}
prevCount = curCount
}
}
}
Expand Down
Loading