Repository navigation
Add opt-in client spans for scheduling orchestrations and raising events - #186
Conversation
dd1cc49 to
f93799d
Compare
f93799d to
33af269
Compare
33af269 to
6d87985
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Scheduling validation and serialization failures, along with RaiseEvent payload serialization failures, return before tracing starts, leaving failed calls without error spans and requiring regression coverage.
2 open issues
What changed in this PR
Adds opt-in client-side OpenTelemetry tracing, extending the worker tracing from #184 toward the end-to-end visibility requested in #175.
Changes:
- Adds PRODUCER spans for scheduling orchestrations and raising events, including propagation of unsampled orchestration parent contexts.
- Exposes tracer configuration through trailing options on
durabletaskscheduler.NewClient, while preserving default propagation-only behavior. - Adds tracing tests, API documentation, and a changelog entry.
| File | Description |
|---|---|
tracing/tracing.go |
Documents client tracing configuration and span behavior. |
internal/dttrace/client.go |
Implements client span creation, attributes, and error recording. |
durabletaskscheduler/client.go |
Accepts trailing client options for tracing configuration. |
durabletaskscheduler/client_tracing_test.go |
Tests tracing options alongside scheduler version settings. |
client/client_grpc.go |
Instruments scheduling and event calls and propagates producer context. |
client/client_grpc_tracing_test.go |
Tests span metadata, failures, sampling, worker parentage, and disabled behavior. |
CHANGELOG.md |
Announces client tracing and constructor options. |
Review effort: Balanced
6d87985 to
095de1f
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The disabled-mode propagation description incorrectly omits valid unsampled contexts and tracestate, which the implementation preserves and the test explicitly verifies.
1 open issue
2 resolved since last review
Review effort: Balanced
095de1f to
cafe15f
Compare
…ising events Co-authored-by: Copilot App <[email protected]>
Clarify that durabletaskscheduler.NewClient client options are for settings Options does not cover, document global and shared providers for client spans, cover payload externalization failures and constructor option forwarding, and add a changelog entry for client PRODUCER spans. Co-authored-by: Copilot App <[email protected]>
Start the create-orchestration and raise-event PRODUCER spans before applying request options so serialization and validation failures, such as an unserializable payload or a reserved instance ID, are recorded as span errors. Co-authored-by: Copilot App <[email protected]>
Preserve unsampled caller propagation and verify it with standard and worker-compatible tracer providers. Cover request metadata on option failures. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
f13bbba to
ec0f8b1
Compare
Bernd Verst (berndverst)
left a comment
There was a problem hiding this comment.
Post-merge review: The opt-in producer spans and disabled-mode propagation are in place. The main follow-ups are the constructor signature and keeping payload conversion consistent between direct and scheduled operations.
| ctx context.Context, | ||
| options *Options, | ||
| logger api.Logger, | ||
| clientOptions ...durabletaskclient.TaskHubGrpcClientOption, |
There was a problem hiding this comment.
Existing three-argument calls still compile, but callers that assign NewClient to a factory typed func(context.Context, *Options, api.Logger) (*Client, error) now fail to compile. Could we keep that signature and expose the tracer through a separate constructor or DTS options? If the signature change is intentional, please call out the source break in the release notes.
| clientOptions = append(clientOptions, durabletaskclient.WithDefaultVersion(prepared.Versioning.DefaultVersion)) | ||
| configuredOptions = append(configuredOptions, durabletaskclient.WithDefaultVersion(prepared.Versioning.DefaultVersion)) | ||
| } | ||
| configuredOptions = append(configuredOptions, clientOptions...) |
There was a problem hiding this comment.
Appending these options last lets client.WithDataConverter(B) override Options.DataConverter = A for direct operations, while ScheduledTasks() still encodes using A. One client can silently write two payload formats. Please use one effective converter for both paths, or keep the DTS-owned settings authoritative and reject conflicting options.
| var err error | ||
| var span trace.Span | ||
| if c.tracer != nil { | ||
| ctx, span = c.tracer.StartCreateOrchestration(ctx, req.Name, req.Version.GetValue(), |
There was a problem hiding this comment.
This span starts after WithInput has already serialized the payload, unlike RaiseEvent. A slow converter can dominate the call without showing up in the scheduling span duration. Capture the start timestamp before applying options when tracing is enabled, then supply it once the final span name and attributes are known.


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
f13bbbab9b2180b30376531205f3f86875c4ad30↑ Disabled-tracing docs now match the unsampled propagation test.
↓ Current-head DTS emulator and race CI are queued.
Relates to #175. Stacked on #184.
Summary
Adds opt-in client-side OpenTelemetry spans that match durabletask-python and durabletask-dotnet:
ScheduleNewOrchestrationcreate_orchestration:<name>orcreate_orchestration:<name>@(<version>)durabletask.type=orchestration,durabletask.task.name,durabletask.task.instance_id,durabletask.task.version(when set),durabletask.task.execution_id(when known; not set by the current public scheduling options)RaiseEventorchestration_event:<event>durabletask.type=event,durabletask.task.name,durabletask.event.target_instance_idMicrosoft.DurableTaskinstrumentation scope.ScheduleNewOrchestrationsends the PRODUCER span as the orchestration's parent trace context, so the worker's orchestration span (Add opt-in replay-aware OpenTelemetry spans (orchestration, activity, timer) #184) nests under it. Without a caller span, the PRODUCER span becomes the root of the trace. That context is sent even when the span is unsampled, which keeps the sampling decision and tracestate for downstream spans, like the other SDKs.API
client.WithTracerProvider(trace.TracerProvider)enables client spans. Any provider works, includingotel.GetTracerProvider();tracing.WithIDGeneratorandtracing.WithSamplerare needed only for worker tracing because client spans are live and never reconstructed. A provider configured for the worker can be shared with the client. A nil provider disables tracing.durabletaskscheduler.NewClientnow takes optional trailingclient.TaskHubGrpcClientOptionvalues for settingsOptionsdoes not cover, such asclient.WithTracerProvider. Data conversion, large payloads, and the default version should still be configured throughOptions;ScheduledTasks()always encodes withOptions.DataConverter.The application keeps ownership of the provider (resource, sampler, processors, exporter, shutdown).
Not in this PR
Orchestration-side event send/receive spans and entity spans are planned for later layers of the stack.