@@ -340,6 +340,7 @@ type TaskProcessor struct {
340340 taskProcessingLoop metrics.Timer
341341 tasksInProcess metrics.GaugeVec
342342 gpuTasksInProcess metrics.GaugeVec
343+ masterTaskDurationVec metrics.TimerVec
343344 taskDurationVec metrics.TimerVec
344345 taskProcessingDuration metrics.Timer
345346
@@ -407,6 +408,7 @@ func (p *TaskProcessor) resetReservePool(tasks []*models.Task) {
407408func (p * TaskProcessor ) ResetLeaderMetrics () {
408409 p .reservePoolCPULimit .Set (0 )
409410 p .taskDurationVec .Reset ()
411+ p .masterTaskDurationVec .Reset ()
410412}
411413
412414func (p * TaskProcessor ) initRateLimiter (tasks []* models.Task ) {
@@ -493,6 +495,7 @@ func (p *TaskProcessor) RegisterMetrics(r metrics.Registry) {
493495 p .taskProcessingLoop = r .Timer ("task_processing_loop" )
494496 p .tasksInProcess = r .GaugeVec ("tasks_in_process" , []string {labelAction , labelProcessingState })
495497 p .taskDurationVec = r .TimerVec ("task_duration_vec" , []string {labelTask , labelHost , labelProcessingState })
498+ p .masterTaskDurationVec = r .TimerVec ("master_task_duration_vec" , []string {labelTask , labelHost , labelProcessingState })
496499 p .gpuTasksInProcess = r .GaugeVec ("gpu_tasks_in_process" , []string {labelAction , labelProcessingState })
497500 p .taskProcessingDuration = r .DurationHistogram ("task_processing_duration" , metrics .NewDurationBuckets (
498501 time .Minute ,
@@ -527,6 +530,7 @@ func (p *TaskProcessor) RegisterMetrics(r metrics.Registry) {
527530
528531func (p * TaskProcessor ) resetLoopMetrics () {
529532 p .taskDurationVec .Reset ()
533+ p .masterTaskDurationVec .Reset ()
530534 for _ , action := range walle .HostActions {
531535 for _ , state := range models .TaskProcessingStates {
532536 p .tasksInProcess .With (map [string ]string {
@@ -560,6 +564,13 @@ func (p *TaskProcessor) initLoopMetrics(tasks []*models.Task) {
560564 labelHost : t .Hosts [0 ],
561565 labelProcessingState : string (t .ProcessingState ),
562566 }).RecordDuration (time .Since (time .Time (t .CreatedAt )))
567+ if len (t .GetMasters ()) > 0 {
568+ p .masterTaskDurationVec .With (map [string ]string {
569+ labelTask : string (t .ID ),
570+ labelHost : t .Hosts [0 ],
571+ labelProcessingState : string (t .ProcessingState ),
572+ }).RecordDuration (time .Since (time .Time (t .CreatedAt )))
573+ }
563574 }
564575 }
565576}
0 commit comments