From 754c66674b265a0cc6b224962854e6c8a6dd5044 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 24 Jun 2021 10:17:55 -0700 Subject: [PATCH] Add missing activity failure metric (#479) --- internal/internal_task_pollers.go | 5 +++++ test/integration_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/internal/internal_task_pollers.go b/internal/internal_task_pollers.go index 37c4547a9..c2f060cfe 100644 --- a/internal/internal_task_pollers.go +++ b/internal/internal_task_pollers.go @@ -873,10 +873,15 @@ func (atp *activityTaskPoller) ProcessTask(task interface{}) error { executionStartTime := time.Now() // Process the activity task. request, err := atp.taskHandler.Execute(atp.taskQueueName, activityTask.task) + // err is returned in case of internal failure, such as unable to propagate context or context timeout. if err != nil { activityMetricsScope.Counter(metrics.ActivityExecutionFailedCounter).Inc(1) return err } + // in case if activity execution failed, request should be of type RespondActivityTaskFailedRequest + if _, ok := request.(*workflowservice.RespondActivityTaskFailedRequest); ok { + activityMetricsScope.Counter(metrics.ActivityExecutionFailedCounter).Inc(1) + } activityMetricsScope.Timer(metrics.ActivityExecutionLatency).Record(time.Since(executionStartTime)) if request == ErrActivityResultPending { diff --git a/test/integration_test.go b/test/integration_test.go index 7b39307a3..9441ddc2f 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -241,6 +241,7 @@ func (ts *IntegrationTestSuite) TestActivityRetryOnError() { ts.assertMetricsCounters( "temporal_request", 7, "temporal_request_attempt", 7, + "temporal_activity_execution_failed", 2, "temporal_workflow_task_queue_poll_succeed", 1, "temporal_long_request", 8, "temporal_long_request_attempt", 8,