Skip to content

Commit 468dee0

Browse files
evansandovalEvan Sandoval
andauthored
Add attempt number to structured activity logger (#1020)
Co-authored-by: Evan Sandoval <[email protected]>
1 parent c0ca78d commit 468dee0

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/main/java/com/uber/cadence/internal/logging/LoggerTag.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public class LoggerTag {
2525
public static final String TASK_LIST = "TaskList";
2626
public static final String WORKFLOW_ID = "WorkflowID";
2727
public static final String WORKFLOW_TYPE = "WorkflowType";
28+
public static final String ATTEMPT = "Attempt";
2829
}

src/main/java/com/uber/cadence/internal/worker/ActivityWorker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ public void handle(PollForActivityTaskResponse task) throws Exception {
144144
MDC.put(LoggerTag.ACTIVITY_TYPE, task.getActivityType().getName());
145145
MDC.put(LoggerTag.WORKFLOW_ID, task.getWorkflowExecution().getWorkflowId());
146146
MDC.put(LoggerTag.RUN_ID, task.getWorkflowExecution().getRunId());
147+
MDC.put(LoggerTag.ATTEMPT, String.valueOf(task.getAttempt()));
147148

148149
propagateContext(task);
149150
Span span = spanFactory.spanForExecuteActivity(task);
@@ -175,6 +176,7 @@ public void handle(PollForActivityTaskResponse task) throws Exception {
175176
MDC.remove(LoggerTag.ACTIVITY_TYPE);
176177
MDC.remove(LoggerTag.WORKFLOW_ID);
177178
MDC.remove(LoggerTag.RUN_ID);
179+
MDC.remove(LoggerTag.ATTEMPT);
178180
unsetCurrentContext();
179181
}
180182
}

0 commit comments

Comments
 (0)