Skip to content

Document and exercise enabled replay-aware tracing - #193

Draft
andystaples wants to merge 2 commits into
andystaples-tracing-entity-spansfrom
andystaples-tracing-samples-and-e2e
Draft

andystaples wants to merge 2 commits into
andystaples-tracing-entity-spansfrom
andystaples-tracing-samples-and-e2e

Conversation

@andystaples

@andystaples andystaples commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #192. Resolves #175.

Summary

Completes the opt-in, replay-aware tracing stack with documentation, an enabled-mode sample, and end-to-end coverage. Durable Task Scheduler persists and forwards trace context but doesn't emit durable orchestration, activity, timer, sub-orchestration, or entity spans, or export spans to an application's backend. SDK tracing is the supported way to get those spans into any OpenTelemetry-compatible backend, next to the application's own spans.

  • Tracing guide (tracing/README.md, tracing package docs, root README):
    • Enablement with an application-owned provider, both required wrappers, error handling (tracing.ErrUnsupportedTracerProvider), and shutdown order (worker, client, then provider).
    • Logical spans, not execution-turn spans: one orchestration:<name> SERVER span per execution (per continue-as-new generation), from the first traced dispatch to completion. Dispatches and replays emit no span. A running, suspended, or never-completing orchestration has no exported orchestration span yet, so its exported children can appear under a parent that the backend doesn't show until completion.
    • Service-side telemetry and duplicates: DTS doesn't emit durable spans. If another component emits durable spans for the same work into the same backend, enable only one source. Omitting client.WithWorkerTracerProvider and client.WithTracerProvider keeps the SDK silent. SDK spans use the Microsoft.DurableTask scope and the provider's resource.
    • Span catalog, export timing, attributes, and sampling, plus a parity table against durabletask-dotnet (gRPC), durabletask-python, and durabletask-js.
  • Sample (samples/distributedtracing): passes one provider to client.WithWorkerTracerProvider and client.WithTracerProvider, builds the resource with resource.New (service name, environment, telemetry SDK), and exports over OTLP/HTTP to a collector. It verifies that the collector received the caller, create-orchestration, orchestration, activity CLIENT and SERVER, timer, and application HTTP spans with their expected kinds. The README explains how to forward the collector to Jaeger, Azure Monitor, or another OTLP backend.
  • DTS end-to-end test (tests/durabletaskscheduler/dts_tracing_enabled_test.go): uses an explicit provider and an in-memory exporter, without changing the global provider, and asserts the exact exported span set, with a guard against late duplicates:
    • caller → create_orchestration PRODUCER → orchestration SERVER → sub-orchestration and activity CLIENT/SERVER; timer INTERNAL; client RaiseEvent and orchestrator SendEvent PRODUCER spans. All SDK spans use the Microsoft.DurableTask scope.
    • A failing activity has error status on both spans, durabletask.task.status=Failed on the SERVER span, and the calling orchestration's instance ID and an integer task ID.
    • A continue-as-new pair exports two orchestration spans with distinct span IDs under the same create span.
    • Event receipt emits no CONSUMER span and doesn't reparent the receiver.
    • Orchestration entity signals and calls are PRODUCER/CLIENT children. Entity executions are CONSUMER/SERVER independent roots without links. Both sides carry durabletask.task.operation and durabletask.entity.operation, and successful operations leave the status unset. An application span started from EntityContext.Context() nests under its operation span. Client SignalEntity emits no span.
    • The disabled-mode tests in dts_tracing_tree_test.go still assert propagation without SDK spans.
  • Changelog: the Unreleased tracing entries now describe the final behavior.

Parity

Go .NET gRPC Python JavaScript
Enabled by default No, opt in with injected providers Yes, ActivitySource (needs a listener) Yes, global provider; opt out with emit_trace_spans=False Yes, global @opentelemetry/api
Scope Microsoft.DurableTask Microsoft.DurableTask durabletask Microsoft.DurableTask
Orchestration span One logical span per execution One logical span per execution One logical span per execution One span per dispatch
No caller context New root No orchestration span New root Active context, or root
Export timing After the completion is accepted Before acceptance Before acceptance Before acceptance
Entity spans Core names: CLIENT/PRODUCER caller, SERVER/CONSUMER execution None Execution-only SERVER Orchestration-side call_entity/signal_entity, client signal_entity, entity:lock_request
Success status Unset Unset Unset OK

Activity and sub-orchestration CLIENT/SERVER spans, timer INTERNAL spans, and create-orchestration, raise-event, and send-event PRODUCER spans exist in all four SDKs. No SDK emits an event-receipt CONSUMER span.

Limitations

  • Telemetry is best effort in both directions, not exactly once. Retried or redelivered work can export duplicate spans. If the backend accepts a completion but the reply is lost and the retry reports the work item gone, that completion's spans are lost.
  • Events carry no trace context, so there's no receipt CONSUMER span or sender-to-receiver join.
  • V2 entity operations carry no parent trace context. Entity execution spans are independent roots without synthetic links.
  • Signals and orchestration starts from an entity carry the operation's trace context on the action, but DTS doesn't currently forward it, so they don't join the trace. The SDK doesn't emit Core's entity-started PRODUCER spans.
  • Client SignalEntity emits no span and propagates only a sampled caller context, like the .NET gRPC SDK.
  • Entity locks emit no spans.

The DTS tests run in PR validation through DTS_EMULATOR_ENDPOINT and skip when no DTS target is configured. Tracing stays opt-in.

@andystaples
andystaples force-pushed the andystaples-tracing-samples-and-e2e branch from e3a5f2a to 320dd7a Compare November 20, 2026 20:21
@andystaples
andystaples added this pull request to stack #194 November 23, 2026 17:09
@andystaples
andystaples marked this pull request as ready for review November 23, 2026 17:09
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:09
@andystaples
andystaples marked this pull request as draft November 23, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The tracing README incorrectly labels Python entity-operation spans as unimplemented and needs to distinguish Python’s SERVER signal spans from Go/Core’s CONSUMER spans.

1 open issue
What changed in this PR

Completes the replay-aware tracing stack with an enabled OTLP sample, end-to-end coverage, and documentation for application-owned telemetry. Tracing remains opt-in.

Changes:

  • Enables client and worker tracing in the sample, with worker shutdown before provider flushing.
  • Adds enabled-mode tests for span parentage, independent entity roots, and entity failures.
  • Documents span lifecycles, sampling, SDK parity, and delivery limitations.
File Description
tracing/​tracing.go Adds a package-doc pointer to the tracing guide.
tracing/​README.md Adds enablement, span semantics, parity, and limitations guidance.
tests/​tracingtree/​tracingtree.go Clarifies the default tracing behavior in comments.
tests/​durabletaskscheduler/​dts_tracing_tree_test.go Updates comments describing disabled-mode assertions.
tests/​durabletaskscheduler/​dts_tracing_enabled_test.go Adds enabled-mode span-tree and entity tracing coverage.
samples/​distributedtracing/​README.md Documents enabled tracing and provider lifecycle.
samples/​distributedtracing/​distributedtracing.go Enables tracing and verifies durable-span collector receipt.
README.md Updates tracing guidance and provider configuration examples.

Review effort: Balanced

Comment thread tracing/README.md Outdated
Comment on lines +105 to +113
| Entity signal/call and operation execution | DurableTask.Core PRODUCER/CLIENT and CONSUMER/SERVER | Not implemented | Not implemented |
| Client entity signal | No span; sampled caller context propagated | None | No span; caller context propagated |
| Entity lock acquisition/release | No spans | No spans | No spans |
| Persisted span reconstruction integration | Public SDK ID-generator/sampler wrappers | Deferred spans via OTel SDK internals | `Activity` reconstruction helpers |

Entity tracing matches the
[DurableTask.Core reference](https://github.com/Azure/durabletask/tree/main/src/DurableTask.Core/Tracing);
it is beyond the current Python and .NET gRPC tracing surfaces, not a claim that
those SDKs emit entity spans.
andystaples and others added 2 commits November 23, 2026 12:47
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Document that DTS doesn't emit durable spans, logical versus execution-turn
spans, and duplicate-source guidance. Add a durabletask-js column and the
enablement, scope, root, export-timing, and status rows to the parity table,
and correct the Python and JavaScript entity rows. Reconcile the changelog.

Extend the enabled DTS E2E test with the Microsoft.DurableTask scope, unset
success status, entity operation and integer task ID attributes, an activity
failure, a continue-as-new generation pair, an application span under an
entity operation, and a late-duplicate guard. The sample now uses a default
resource, checks span kinds on receipt, and points readers at OTLP backends.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@andystaples
andystaples force-pushed the andystaples-tracing-samples-and-e2e branch from 320dd7a to d76c179 Compare November 23, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide replay-aware orchestration traces in an application OTLP collector

2 participants