feat(client): propagate caller trace context on ScheduleNewOrchestration#134
Draft
ahmedmuhsin wants to merge 1 commit into
Draft
feat(client): propagate caller trace context on ScheduleNewOrchestration#134ahmedmuhsin wants to merge 1 commit into
ahmedmuhsin wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TaskHubGrpcClient.ScheduleNewOrchestrationnow starts acreate_orchestrationclient span and propagates its trace context to the server viaCreateInstanceRequest.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 client —TraceHelper.StartActivityForNewOrchestrationsetsCreateInstanceRequest.ParentTraceContextbeforeStartInstance.DurableTask.Core— the .NET tracing helper this is adapted from.ExecutionStartedEvent.ParentTraceContext.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.StartInstanceparsesParentTraceContextto parent the orchestration span.Changes
CreateInstanceRequest.parentTraceContext(field 9). Field numbers 7/8/10 (executionId / tags / requestTime) exist in newer upstream revisions and arereservedhere soparentTraceContextkeeps the wire-compatible number 9 that the host reads.create_orchestrationspan (mirroringbackend/client.go) and setParentTraceContextviahelpers.TraceContextFromSpan. An unsampled span yields no context, so nothing is fabricated when tracing is off.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_PropagatesParentTraceContextstands up a capture sidecar over bufconn and asserts the received request'sParentTraceContextcarries the caller span's trace ID.Note
Honoring
ParentTraceContexton 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.