From 9546636275aeebb3f3fbad41441009c4e8562442 Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Tue, 24 Feb 2026 14:59:00 -0500 Subject: [PATCH] chore(engine): don't observe task execution time if there's no assign time (#20956) --- pkg/engine/internal/scheduler/scheduler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/engine/internal/scheduler/scheduler.go b/pkg/engine/internal/scheduler/scheduler.go index a592a9078e..e3880f7d98 100644 --- a/pkg/engine/internal/scheduler/scheduler.go +++ b/pkg/engine/internal/scheduler/scheduler.go @@ -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()) }