Skip to content

feat(client): propagate caller trace context on ScheduleNewOrchestration#134

Draft
ahmedmuhsin wants to merge 1 commit into
microsoft:mainfrom
ahmedmuhsin:ahmedmuhsin/client-trace-context
Draft

feat(client): propagate caller trace context on ScheduleNewOrchestration#134
ahmedmuhsin wants to merge 1 commit into
microsoft:mainfrom
ahmedmuhsin:ahmedmuhsin/client-trace-context

Conversation

@ahmedmuhsin

Copy link
Copy Markdown

Summary

TaskHubGrpcClient.ScheduleNewOrchestration now starts a create_orchestration client span and propagates its trace context to the server via CreateInstanceRequest.parentTraceContext, so the scheduled orchestration links into the caller's distributed trace.

Why this is a parity fix

The same propagation already exists everywhere else in the ecosystem:

  • Microsoft.DurableTask (.NET) gRPC clientTraceHelper.StartActivityForNewOrchestration sets CreateInstanceRequest.ParentTraceContext before StartInstance.
  • DurableTask.Core — the .NET tracing helper this is adapted from.
  • The in-proc Azure Functions WebJobs extension — stamps ExecutionStartedEvent.ParentTraceContext.
  • durabletask-go's own in-process backend client (backend/client.go) — already does exactly this.

Only the durabletask-go gRPC client lacked it — an internal asymmetry with its own in-process client. The server already reads the field: the Azure Functions Durable Task extension's TaskHubGrpcServer.StartInstance parses ParentTraceContext to parent the orchestration span.

Changes

  • proto: add CreateInstanceRequest.parentTraceContext (field 9). Field numbers 7/8/10 (executionId / tags / requestTime) exist in newer upstream revisions and are reserved here so parentTraceContext keeps the wire-compatible number 9 that the host reads.
  • client: start a create_orchestration span (mirroring backend/client.go) and set ParentTraceContext via helpers.TraceContextFromSpan. An unsampled span yields no context, so nothing is fabricated when tracing is off.
  • regenerated internal/protos/orchestrator_service.pb.go — the meaningful change is the new field + getter; the remaining churn is rawDesc reserialization that PR validation regenerates.

Test

Test_ScheduleNewOrchestration_PropagatesParentTraceContext stands up a capture sidecar over bufconn and asserts the received request's ParentTraceContext carries the caller span's trace ID.

Note

Honoring ParentTraceContext on the server side of a durabletask-go task hub (so a Go-hosted backend parents the orchestration span too) is left as a separate change; the Azure Functions host already honors it today.

The gRPC client now attaches the caller's trace context to the schedule request so the orchestration links into the caller's distributed trace.

- proto: add CreateInstanceRequest.parentTraceContext (field 9), matching the field number the server reads upstream (the Azure Functions Durable Task extension's TaskHubGrpcServer.StartInstance already parses it to parent the orchestration span). Field numbers 7 (executionId), 8 (tags) and 10 (requestTime) exist in newer upstream revisions and are reserved so parentTraceContext keeps the wire-compatible number 9.

- client: ScheduleNewOrchestration starts a client 'create_orchestration' span (mirroring the in-process backend client) and sets ParentTraceContext from it via helpers.TraceContextFromSpan. An unsampled span yields no trace context (parent-based sampling), so nothing is fabricated when tracing is off.

test: Test_ScheduleNewOrchestration_PropagatesParentTraceContext stands up a capture sidecar over bufconn and asserts the received request's ParentTraceContext carries the caller span's trace ID.

Note: internal/protos/orchestrator_service.pb.go was regenerated for the proto change (protoc v3.12.4 / protoc-gen-go v1.31.0 to match the repo's generated style); the meaningful diff is the new field + getter, with the remainder being rawDesc reserialization that PR validation normalizes by regenerating.
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.

1 participant