Skip to content

Commit

Permalink
worker/server: update metrics on requeue
Browse files Browse the repository at this point in the history
When requeuing a job the next worker requesting the job would decrement
pending counter, but the pending counter only ever got incremented once,
when the job was first enqueued. Thus make sure to increment the pending
counter when a job is requeued.
  • Loading branch information
croissanne committed Nov 5, 2024
1 parent 70afb7a commit 4340f1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/worker/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ func (s *Server) RequeueOrFinishJob(token uuid.UUID, maxRetries uint64, result j
}
}

err = s.jobs.RequeueOrFinishJob(jobId, maxRetries, result)
requeued, err := s.jobs.RequeueOrFinishJob(jobId, maxRetries, result)
if err != nil {
switch err {
case jobqueue.ErrNotRunning:
Expand All @@ -718,6 +718,14 @@ func (s *Server) RequeueOrFinishJob(token uuid.UUID, maxRetries uint64, result j
}
}

if requeued {
jobInfo, err := s.jobInfo(jobId, nil)
if err != nil {
return fmt.Errorf("error requeueing job: %w", err)
}
prometheus.EnqueueJobMetrics(jobInfo.JobType, jobInfo.Channel)
}

jobType, err := s.JobType(jobId)
if err != nil {
return err
Expand Down

0 comments on commit 4340f1e

Please sign in to comment.