Skip to content

Commit f36b721

Browse files
Document ContinueAsNew trace behavior
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 86a5fdf commit f36b721

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

docs/telemetry/distributed-tracing.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,24 @@ Traces are automatically correlated across:
209209
- Orchestration → Activity
210210
- Client → Orchestration
211211

212+
### Continue-as-new trace behavior
213+
214+
By default, `ContinueAsNew` preserves the current distributed trace context. This keeps generations of the same orchestration instance connected in one trace.
215+
216+
For long-running or periodic orchestrations, use `ContinueAsNewOptions` with `ContinueAsNewTraceBehavior.StartNewTrace` to start the next generation in a fresh trace:
217+
218+
```csharp
219+
context.ContinueAsNew(
220+
newVersion: null,
221+
input: nextInput,
222+
options: new ContinueAsNewOptions
223+
{
224+
TraceBehavior = ContinueAsNewTraceBehavior.StartNewTrace,
225+
});
226+
```
227+
228+
The orchestration instance ID is preserved, but the next generation gets a new trace ID. Use this when each loop or cycle should be independently visible in your telemetry backend.
229+
212230
### Example Trace Hierarchy
213231

214232
```text

docs/telemetry/traces/semantic-conventions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Attributes:
6969
| durabletask.task.execution_id  | Execution ID of the enqueued orchestration  |
7070
| exception.*  | Exception details on failure. |
7171

72+
##### Continue-as-new fresh traces
73+
74+
When `ContinueAsNew` is used with `ContinueAsNewTraceBehavior.StartNewTrace`, DurableTask emits this producer span shape for the next generation even though no external client call occurred. The producer span is the root of a new trace, starts at the next generation's orchestration-created timestamp, and ends when the worker establishes the trace before running the generation.
75+
76+
The following `orchestration:{orchestrationName}(@{orchestrationVersion})?` server span is a child of this producer span. The orchestration instance ID is preserved, but the new generation is not parented to the previous generation's trace.
77+
7278
#### Client: Starting a sub-orchestration
7379

7480
Represents enqueueing and waiting for a sub-orchestration to complete

0 commit comments

Comments
 (0)