Skip to content

Commit

Permalink
log average task duration (twitter#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanetteBruno authored Jul 21, 2021
1 parent d46edf0 commit d36802b
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions scheduler/server/stateful_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,16 +925,28 @@ func (s *statefulScheduler) scheduleTasks() {

preventRetries := bool(task.NumTimesTried >= s.config.MaxRetriesPerTask)

avgDur := -1
iface, ok := s.taskDurations.Get(durationID)
if ok {
ad, ok := iface.(*averageDuration)
if !ok {
log.Errorf("getting task duration, object was not *averageDuration type! (it is %s)", reflect.TypeOf(ad))
} else {
avgDur = int(ad.duration)
}
}

log.WithFields(
log.Fields{
"jobID": jobID,
"taskID": taskID,
"node": nodeSt.node,
"requestor": requestor,
"jobType": jobType,
"tag": tag,
"taskDef": taskDef,
"durationID": durationID,
"jobID": jobID,
"taskID": taskID,
"node": nodeSt.node,
"requestor": requestor,
"jobType": jobType,
"tag": tag,
"taskDef": taskDef,
"durationID": durationID,
"avgDuration": fmt.Sprintf("%d (sec)", avgDur),
}).Info("Starting taskRunner")

tRunner := &taskRunner{
Expand Down

0 comments on commit d36802b

Please sign in to comment.