Add distributed tracing using opentelemetry#119
Add distributed tracing using opentelemetry#119andystaples wants to merge 11 commits intomicrosoft:mainfrom
Conversation
…com/andystaples/durabletask-python into andystaples/add-distributed-tracing
There was a problem hiding this comment.
Pull request overview
Adds OpenTelemetry-based distributed tracing to the Durable Task Python SDK by propagating W3C trace context through the gRPC protocol and emitting spans for orchestration, activity, sub-orchestration, timer, entity, and event operations.
Changes:
- Introduces
durabletask.internal.tracingwith optional OpenTelemetry helpers for context extraction/injection and span lifecycle management. - Updates worker + client code paths to propagate
TraceContextover gRPC and to create/finish spans across multi-dispatch orchestration replays. - Adds a comprehensive tracing test suite and updates dependency metadata to include OpenTelemetry packages/extras.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/durabletask/test_tracing.py | New unit/integration-style tests covering tracing utilities and replay/lifecycle behavior |
| durabletask/internal/tracing.py | New tracing utility module (optional OpenTelemetry dependency) |
| durabletask/worker.py | Server-side span creation/propagation; persists orchestration + client spans across dispatches |
| durabletask/client.py | Producer spans + parent trace context injection for orchestration creation and entity signals |
| durabletask/internal/helpers.py | Adds parent_trace_context to schedule/sub-orchestration action helpers |
| pyproject.toml | Adds opentelemetry optional dependency extra |
| requirements.txt | Adds OpenTelemetry packages to the dev/test requirements list |
| CHANGELOG.md | Notes improved distributed tracing support |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Can you add a sample for distributed tracing with a README and include screenshots? Can you also add an example of a suborchestration in the sample and screenshots?
durabletask/internal/tracing.py
Outdated
|
|
||
| def create_timer_span_name(orchestration_name: str) -> str: | ||
| """Build a timer span name: ``orchestration:<name>:timer``.""" | ||
| return f"orchestration:{orchestration_name}:timer" |
There was a problem hiding this comment.
Can we put the strings "orchestration", "timer", etc. as constants?
Adds support for Distributed Tracing by passing the trace information for orchestrations passed in the gRPC spec to activitites/entities/sub-orchestrations
Compare to the Dotnet SDK: https://github.com/microsoft/durabletask-dotnet
Test orchestrator:
Jaeger profile for fan-out orchestration:

DTS view of the same orchestration:

Entity traces are present but unlinked, until the protobuf changes here are merged and incorporated into backends:
microsoft/durabletask-protobuf#64
Resolves #97