Skip to content

Commit

Permalink
Adding attempt number into MDC context for better diagnosing (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercanillas authored Aug 21, 2024
1 parent 4eaeb9e commit f2e113a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ private LoggerTag() {}
public static final String WORKER_TYPE = "WorkerType";
public static final String SIDE_EFFECT_ID = "SideEffectId";
public static final String CHILD_WORKFLOW_ID = "ChildWorkflowId";
public static final String ATTEMPT = "Attempt";
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public void handle(ActivityTask task) throws Exception {
MDC.put(LoggerTag.WORKFLOW_ID, pollResponse.getWorkflowExecution().getWorkflowId());
MDC.put(LoggerTag.WORKFLOW_TYPE, pollResponse.getWorkflowType().getName());
MDC.put(LoggerTag.RUN_ID, pollResponse.getWorkflowExecution().getRunId());
MDC.put(LoggerTag.ATTEMPT, Integer.toString(pollResponse.getAttempt()));

ActivityTaskHandler.Result result = null;
try {
Expand All @@ -257,6 +258,7 @@ public void handle(ActivityTask task) throws Exception {
MDC.remove(LoggerTag.WORKFLOW_ID);
MDC.remove(LoggerTag.WORKFLOW_TYPE);
MDC.remove(LoggerTag.RUN_ID);
MDC.remove(LoggerTag.ATTEMPT);
if (
// handleActivity throw an exception (not a normal scenario)
result == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ public void handle(LocalActivityAttemptTask attemptTask) throws Exception {
MDC.put(LoggerTag.WORKFLOW_ID, activityTask.getWorkflowExecution().getWorkflowId());
MDC.put(LoggerTag.WORKFLOW_TYPE, activityTask.getWorkflowType().getName());
MDC.put(LoggerTag.RUN_ID, activityTask.getWorkflowExecution().getRunId());
MDC.put(LoggerTag.ATTEMPT, Integer.toString(activityTask.getAttempt()));

slotSupplier.markSlotUsed(
new LocalActivitySlotInfo(
Expand Down Expand Up @@ -506,6 +507,7 @@ public void handle(LocalActivityAttemptTask attemptTask) throws Exception {
MDC.remove(LoggerTag.WORKFLOW_ID);
MDC.remove(LoggerTag.WORKFLOW_TYPE);
MDC.remove(LoggerTag.RUN_ID);
MDC.remove(LoggerTag.ATTEMPT);
}
}

Expand Down

0 comments on commit f2e113a

Please sign in to comment.