chore(engine): don't observe task execution time if there's no assign time (#20956)

This commit is contained in:
Robert Fratto
2026-02-24 14:59:00 -05:00
committed by GitHub
parent 13c964d4b8
commit 9546636275

View File

@@ -285,9 +285,14 @@ func (s *Scheduler) handleTaskStatus(ctx context.Context, worker *workerConn, ms
owner.Unassign(task)
}
if task.status.State == workflow.TaskStateCompleted {
if task.status.State == workflow.TaskStateCompleted && !task.assignTime.IsZero() {
// The execution time of the task is the duration from when it was
// first assigned to when we received the completion status.
//
// We skip the observation when assignTime is zero, which can happen
// when a task completes before we can process the assignment. If we
// didn't skip these, we'd record an observation of the maximum
// time.Duration value (290 years).
s.metrics.taskExecSeconds.Observe(time.Since(task.assignTime).Seconds())
}