worker/server: update metrics on requeue
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.
This commit is contained in:
parent
056b3c5ea6
commit
a971f9340b
2 changed files with 14 additions and 1 deletions
|
|
@ -68,6 +68,11 @@ func DequeueJobMetrics(pending time.Time, started time.Time, jobType, tenant, ar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RequeueJobMetrics(jobType, tenant string) {
|
||||||
|
PendingJobs.WithLabelValues(jobType, tenant).Inc()
|
||||||
|
RunningJobs.WithLabelValues(jobType, tenant).Dec()
|
||||||
|
}
|
||||||
|
|
||||||
func CancelJobMetrics(started time.Time, jobType, tenant string) {
|
func CancelJobMetrics(started time.Time, jobType, tenant string) {
|
||||||
if !started.IsZero() {
|
if !started.IsZero() {
|
||||||
RunningJobs.WithLabelValues(jobType, tenant).Dec()
|
RunningJobs.WithLabelValues(jobType, tenant).Dec()
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
if err != nil {
|
||||||
switch err {
|
switch err {
|
||||||
case jobqueue.ErrNotRunning:
|
case jobqueue.ErrNotRunning:
|
||||||
|
|
@ -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.RequeueJobMetrics(jobInfo.JobType, jobInfo.Channel)
|
||||||
|
}
|
||||||
|
|
||||||
jobType, err := s.JobType(jobId)
|
jobType, err := s.JobType(jobId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue