Skip to content

Commit 1d427b0

Browse files
torosentCopilot
andcommitted
fix: create_orchestration span kind to PRODUCER, error status on failed orchestration
1. Changed create_orchestration span from INTERNAL (default) to PRODUCER, matching .NET SDK's StartActivityForNewOrchestration which uses ActivityKind.Producer. 2. Set ERROR status on orchestration span when the orchestration fails, matching .NET SDK's pattern of checking CompleteOrchestration action for FAILED status before disposing the span. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 78afdab commit 1d427b0

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import io.grpc.*;
1212
import io.opentelemetry.api.trace.Span;
13+
import io.opentelemetry.api.trace.SpanKind;
1314
import io.opentelemetry.context.Scope;
1415

1516
import javax.annotation.Nullable;
@@ -144,7 +145,7 @@ public String scheduleNewOrchestrationInstance(
144145
spanAttrs.put(TracingHelper.ATTR_INSTANCE_ID, instanceId);
145146
Span createSpan = TracingHelper.startSpan(
146147
TracingHelper.TYPE_CREATE_ORCHESTRATION + ":" + orchestratorName,
147-
null, null, spanAttrs);
148+
null, SpanKind.PRODUCER, spanAttrs);
148149
Scope createScope = createSpan.makeCurrent();
149150

150151
try {

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.grpc.*;
1414
import io.opentelemetry.api.trace.Span;
1515
import io.opentelemetry.api.trace.SpanKind;
16+
import io.opentelemetry.api.trace.StatusCode;
1617
import io.opentelemetry.context.Scope;
1718

1819
import java.time.Duration;
@@ -231,8 +232,20 @@ public void startAndBlock() {
231232
throw new RuntimeException(e);
232233
}
233234

234-
// End the orchestration span for every dispatch
235+
// End the orchestration span, setting error status if the orchestration failed
235236
if (orchestrationSpan != null) {
237+
for (OrchestratorAction action : taskOrchestratorResult.getActions()) {
238+
if (action.getOrchestratorActionTypeCase() == OrchestratorAction.OrchestratorActionTypeCase.COMPLETEORCHESTRATION) {
239+
CompleteOrchestrationAction complete = action.getCompleteOrchestration();
240+
if (complete.getOrchestrationStatus() == OrchestrationStatus.ORCHESTRATION_STATUS_FAILED) {
241+
String errorMsg = complete.hasFailureDetails()
242+
? complete.getFailureDetails().getErrorMessage()
243+
: "Orchestration failed";
244+
orchestrationSpan.setStatus(StatusCode.ERROR, errorMsg);
245+
}
246+
break;
247+
}
248+
}
236249
orchestrationSpan.end();
237250
}
238251

0 commit comments

Comments
 (0)