Skip to content

Commit f2a2bc7

Browse files
committed
fix(tracing): improve orchestration span handling and timestamp usage for full lifecycle coverage
1 parent 5c0c9fc commit f2a2bc7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ public void startAndBlock() {
195195

196196
// Start the orchestration span BEFORE execution so child spans
197197
// (activities, timers) are nested under it. Use setSpanId() to give
198-
// all dispatches the same span ID — Jaeger deduplicates by span ID,
199-
// keeping the latest end time (matching .NET's SetSpanId pattern).
198+
// all dispatches the same span ID for deduplication
199+
// (matching .NET's SetSpanId pattern).
200200
Span orchestrationSpan = null;
201201
TraceContext orchestrationSpanContext = null;
202202
if (orchTraceCtx != null) {
@@ -205,11 +205,11 @@ public void startAndBlock() {
205205
orchSpanAttrs.put(TracingHelper.ATTR_TASK_NAME, orchName);
206206
orchSpanAttrs.put(TracingHelper.ATTR_INSTANCE_ID, orchestratorRequest.getInstanceId());
207207

208-
Instant spanStartTime = null;
209-
if (startedHistoryEvent != null && startedHistoryEvent.hasTimestamp()) {
210-
spanStartTime = DataConverter.getInstantFromTimestamp(
211-
startedHistoryEvent.getTimestamp());
212-
}
208+
// Use ExecutionStartedEvent timestamp so the orchestration span
209+
// covers the full lifecycle from creation to completion
210+
Instant spanStartTime = startedHistoryEvent.hasTimestamp()
211+
? DataConverter.getInstantFromTimestamp(startedHistoryEvent.getTimestamp())
212+
: null;
213213

214214
orchestrationSpan = TracingHelper.startSpanWithStartTime(
215215
TracingHelper.TYPE_ORCHESTRATION + ":" + orchName,
@@ -227,7 +227,7 @@ public void startAndBlock() {
227227
&& orchestratorRequest.getOrchestrationTraceContext().getSpanID().getValue() != null
228228
&& !orchestratorRequest.getOrchestrationTraceContext().getSpanID().getValue().isEmpty()) {
229229
orchSpanId = orchestratorRequest.getOrchestrationTraceContext().getSpanID().getValue();
230-
} else if (orchTraceCtx != null) {
230+
} else {
231231
// Derive from parent span ID by hashing with instance ID
232232
String parentSpanId = TracingHelper.extractSpanIdFromTraceparent(
233233
orchTraceCtx.getTraceParent());
-27.4 KB
Loading

0 commit comments

Comments
 (0)