From ee6cabf3d9efaa06b0017a2e10c976cd8af0359b Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 3 Oct 2024 15:55:53 -0700 Subject: [PATCH] ensure WorkflowTaskExecutionFailureCounter is called with a tag --- internal/internal_event_handlers.go | 4 ++-- internal/internal_task_pollers.go | 2 +- internal/internal_workflow.go | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index b7897df1a..82a9785be 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -1170,7 +1170,7 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( } defer func() { if p := recover(); p != nil { - weh.metricsHandler.Counter(metrics.WorkflowTaskExecutionFailureCounter).Inc(1) + incrementWorkflowTaskFailureCounter(weh.metricsHandler, "NonDeterminismError") topLine := fmt.Sprintf("process event for %s [panic]:", weh.workflowInfo.TaskQueueName) st := getStackTraceRaw(topLine, 7, 0) weh.Complete(nil, newWorkflowPanicError(p, st)) @@ -1373,7 +1373,7 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessMessage( ) error { defer func() { if p := recover(); p != nil { - weh.metricsHandler.Counter(metrics.WorkflowTaskExecutionFailureCounter).Inc(1) + incrementWorkflowTaskFailureCounter(weh.metricsHandler, "NonDeterminismError") topLine := fmt.Sprintf("process message for %s [panic]:", weh.workflowInfo.TaskQueueName) st := getStackTraceRaw(topLine, 7, 0) weh.Complete(nil, newWorkflowPanicError(p, st)) diff --git a/internal/internal_task_pollers.go b/internal/internal_task_pollers.go index 00b77c9d1..71c447c77 100644 --- a/internal/internal_task_pollers.go +++ b/internal/internal_task_pollers.go @@ -471,7 +471,7 @@ func (wtp *workflowTaskPoller) RespondTaskCompletedWithMetrics( if failWorkflowTask.Cause == enumspb.WORKFLOW_TASK_FAILED_CAUSE_NON_DETERMINISTIC_ERROR { failureReason = "NonDeterminismError" } - metricsHandler.WithTags(metrics.WorkflowTaskFailedTags(failureReason)).Counter(metrics.WorkflowTaskExecutionFailureCounter).Inc(1) + incrementWorkflowTaskFailureCounter(metricsHandler, failureReason) completedRequest = failWorkflowTask } diff --git a/internal/internal_workflow.go b/internal/internal_workflow.go index 7714472bf..ce4eb8986 100644 --- a/internal/internal_workflow.go +++ b/internal/internal_workflow.go @@ -1960,3 +1960,7 @@ func (s *semaphoreImpl) Release(n int64) { panic("Semaphore.Release() released more than held") } } + +func incrementWorkflowTaskFailureCounter(metricsHandler metrics.Handler, failureReason string) { + metricsHandler.WithTags(metrics.WorkflowTaskFailedTags(failureReason)).Counter(metrics.WorkflowTaskExecutionFailureCounter).Inc(1) +}