Skip to content

Commit

Permalink
Tag workflow_task_execution_failed with error type (#1932)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Nov 16, 2023
1 parent 499593f commit a2c8a2b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package io.temporal.internal.worker;

import static io.temporal.serviceclient.MetricsTag.METRICS_TAGS_CALL_OPTIONS_KEY;
import static io.temporal.serviceclient.MetricsTag.TASK_FAILURE_TYPE;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
Expand All @@ -30,6 +31,7 @@
import com.uber.m3.util.ImmutableMap;
import io.temporal.api.common.v1.WorkflowExecution;
import io.temporal.api.enums.v1.TaskQueueKind;
import io.temporal.api.enums.v1.WorkflowTaskFailedCause;
import io.temporal.api.workflowservice.v1.*;
import io.temporal.internal.logging.LoggerTag;
import io.temporal.internal.retryer.GrpcRetryer;
Expand Down Expand Up @@ -370,9 +372,25 @@ public void handle(WorkflowTask task) throws Exception {
}

if (result.getTaskFailed() != null) {
Scope workflowTaskFailureScope = workflowTypeScope;
if (result
.getTaskFailed()
.getCause()
.equals(
WorkflowTaskFailedCause.WORKFLOW_TASK_FAILED_CAUSE_NON_DETERMINISTIC_ERROR)) {
workflowTaskFailureScope =
workflowTaskFailureScope.tagged(
ImmutableMap.of(TASK_FAILURE_TYPE, "NonDeterminismError"));
} else {
workflowTaskFailureScope =
workflowTaskFailureScope.tagged(
ImmutableMap.of(TASK_FAILURE_TYPE, "WorkflowError"));
}
// we don't trigger the counter in case of the legacy query
// (which never has taskFailed set)
workflowTypeScope.counter(MetricsType.WORKFLOW_TASK_EXECUTION_FAILURE_COUNTER).inc(1);
workflowTaskFailureScope
.counter(MetricsType.WORKFLOW_TASK_EXECUTION_FAILURE_COUNTER)
.inc(1);
}
if (nextWFTResponse.isPresent()) {
workflowTypeScope.counter(MetricsType.WORKFLOW_TASK_HEARTBEAT_COUNTER).inc(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class MetricsTag {
public static final String STATUS_CODE = "status_code";
public static final String EXCEPTION = "exception";
public static final String OPERATION_NAME = "operation";
public static final String TASK_FAILURE_TYPE = "failure_reason";

/** Used to pass metrics scope to the interceptor */
public static final CallOptions.Key<Scope> METRICS_TAGS_CALL_OPTIONS_KEY =
Expand Down

0 comments on commit a2c8a2b

Please sign in to comment.