Skip to content

Document and exercise enabled replay-aware tracing - #193

Merged
Tomer Rosenthal (torosent) merged 3 commits into
mainfrom
andystaples-tracing-samples-and-e2e
Dec 1, 2026
Merged

Tomer Rosenthal (torosent) merged 3 commits into
mainfrom
andystaples-tracing-samples-and-e2e

Conversation

@andystaples

@andystaples andystaples commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 687a6b96b470e66bfe52bd0b3a4939616724fdd7

Dimension Assessment Rationale
Change confidence 9/10 ↑ Full repository tests pass with the pinned DTS emulator; enabled and disabled tracing E2E pass three repeated runs.
↑ Build, vet, sample-module tests, and golangci-lint v2.14.0 pass; CHANGELOG entries remain separate.
↑ Docs reflect propagation of unsampled caller context.
↓ OTLP collector export was not exercised end to end on this revision; race tests were not run.

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 Resolved
@andystaples
andystaples force-pushed the andystaples-tracing-samples-and-e2e branch from 320dd7a to d76c179 Compare November 23, 2026 20:08
@andystaples
andystaples force-pushed the andystaples-tracing-samples-and-e2e branch from d76c179 to 8bfb1bb Compare November 30, 2026 20:18
@andystaples
andystaples marked this pull request as ready for review November 30, 2026 20:20
Copilot AI balanced review requested due to automatic review settings November 30, 2026 20:20

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.

🟢 Approval recommended

No active review issues are reported for the tracing documentation, sample, and end-to-end coverage changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@andystaples
andystaples force-pushed the andystaples-tracing-samples-and-e2e branch from 8bfb1bb to 687a6b9 Compare November 30, 2026 23:45
Copilot AI balanced review requested due to automatic review settings November 30, 2026 23:45

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.

🟢 Approval recommended

No active review issues are reported for the tracing documentation, sample, and test changes.

No open issues 🎉

Review effort: Balanced

@torosent
Tomer Rosenthal (torosent) force-pushed the andystaples-tracing-samples-and-e2e branch from 687a6b9 to 924cbec Compare December 1, 2026 00:12
Copilot AI balanced review requested due to automatic review settings December 1, 2026 00:12

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 README overstates the unsampled-tree guarantee without clarifying that honoring parent sampling decisions requires a parent-based sampler.

1 open issue

Review effort: Balanced

Comment thread tracing/README.md Resolved
@torosent
Tomer Rosenthal (torosent) force-pushed the andystaples-tracing-samples-and-e2e branch 2 times, most recently from 0eeb1f8 to cd6e01a Compare December 1, 2026 04:25
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:38

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.

🟢 Approval recommended

No active review issues are recorded for the replay-aware tracing documentation, sample, and end-to-end coverage changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Base automatically changed from andystaples-tracing-entity-spans to main December 1, 2026 16:47
andystaples and others added 3 commits December 1, 2026 08:47
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 <[email protected]>
Clarified the behavior of sampling in orchestration and the use of different samplers.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@torosent
Tomer Rosenthal (torosent) force-pushed the andystaples-tracing-samples-and-e2e branch from 1dcd5bd to 6ea8927 Compare December 1, 2026 16:47
@torosent
Tomer Rosenthal (torosent) merged commit 1ac68d6 into main Dec 1, 2026
8 checks passed

@berndverst Bernd Verst (berndverst) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Post-merge review: The guide, enabled sample, and DTS end-to-end coverage meet the goal without changing the SDK API. The follow-ups below clarify parentage and abandonment and make the collector check verify the HTTP span chain it documents.

Comment thread tracing/README.md

Failures get an error status. Successful spans leave the status unset.

Without caller context, an orchestration becomes the root of a new trace. Its

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we say “without a propagated parent trace context” rather than “without caller context” here and in the span/parity tables? With client tracing enabled, ScheduleNewOrchestration(context.Background(), …) starts a root create_orchestration PRODUCER, and the worker SERVER span is its child. This PR's receiver E2E already asserts that topology. The worker derives a new trace ID only when it receives no valid parent.

Comment thread tracing/README.md

- A running, suspended, or never-completing orchestration has no exported
orchestration span yet. Its exported children can appear under a parent that
your backend doesn't show until the orchestration completes. If the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please distinguish an abandoned work-item dispatch from an execution that never completes. An abandoned dispatch can be redelivered, and the execution can still finish and export its logical span. I'd use “purged before completion” here and let the existing limitation say the abandoned dispatch exports nothing.

if _, ok := found[name]; !ok {
missing = append(missing, name)
for _, want := range expected {
found := false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The collector check can pass with the expected names and kinds in the same trace even if the parentage is wrong or the HTTP CLIENT span is absent. Since the sample documents that HTTP chain, could we name the client span explicitly and verify activity SERVER → HTTP CLIENT → local_trace_target SERVER by span and parent ID?

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

5 participants