Skip to content

Commit 9691eb1

Browse files
authored
Fix exception handling and stale trace context in distributed tracing (#267)
1 parent cbfa05b commit 9691eb1

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

client/src/main/java/com/microsoft/durabletask/DurableTaskGrpcWorker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ public void startAndBlock() {
208208
} catch (Throwable e) {
209209
TracingHelper.endSpan(orchestrationSpan, e);
210210
orchestrationScope.close();
211-
throw e;
211+
if (e instanceof Error) {
212+
throw (Error) e;
213+
}
214+
throw new RuntimeException(e);
212215
}
213216
orchestrationScope.close();
214217
TracingHelper.endSpan(orchestrationSpan, null);

client/src/main/java/com/microsoft/durabletask/OrchestrationRunner.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ public TaskOrchestration create() {
181181
taskOrchestratorResult = taskOrchestrationExecutor.execute(
182182
orchestratorRequest.getPastEventsList(),
183183
orchestratorRequest.getNewEventsList());
184-
} catch (Throwable e) {
184+
} catch (Exception e) {
185185
TracingHelper.endSpan(orchestrationSpan, e);
186-
orchestrationScope.close();
187186
throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
187+
} finally {
188+
orchestrationScope.close();
188189
}
189-
orchestrationScope.close();
190190
TracingHelper.endSpan(orchestrationSpan, null);
191191

192192
OrchestratorService.OrchestratorResponse response = OrchestratorService.OrchestratorResponse.newBuilder()

client/src/main/java/com/microsoft/durabletask/TaskOrchestrationExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,8 @@ private void processEvent(HistoryEvent e) {
887887
this.setVersion(version);
888888
if (startedEvent.hasParentTraceContext()) {
889889
this.parentTraceContext = startedEvent.getParentTraceContext();
890+
} else {
891+
this.parentTraceContext = null;
890892
}
891893
TaskOrchestrationFactory factory = TaskOrchestrationExecutor.this.orchestrationFactories.get(name);
892894
if (factory == null) {

0 commit comments

Comments
 (0)