Skip to content

Conversation

@satvu
Copy link
Member

@satvu satvu commented Jan 22, 2026

Issue describing the changes in this PR

resolves #11574

Related worker PR: Azure/azure-functions-dotnet-worker#3303
Depends on protobuf PR + release: Azure/azure-functions-language-worker-protobuf#98

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional Information

Verified that this works e2e and that custom tags appear in app insights in the portal.

// Status of the invocation (success/failure/canceled)
StatusResult result = 3;

RpcTraceContext trace_context = 5;
Copy link
Member Author

Choose a reason for hiding this comment

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

Will remove this when protobuf is released and updated version is pulled into host repo

return;
}

System.Threading.ExecutionContext.Run(context.AsyncExecutionContext, static state =>
Copy link
Member Author

Choose a reason for hiding this comment

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

Needs to run in correct context to set the correction activity

@satvu satvu marked this pull request as ready for review January 23, 2026 23:59
@satvu satvu requested a review from a team as a code owner January 23, 2026 23:59
Copilot AI review requested due to automatic review settings January 23, 2026 23:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements functionality to propagate trace attributes from language workers back to the host, supporting the broader "app capabilities" feature (#11574). Workers can now send trace context information in their InvocationResponse messages, which the host adds to the current Activity for distributed tracing.

Changes:

  • Added RpcTraceContext trace_context field to the InvocationResponse protobuf message to enable workers to send trace attributes back to the host
  • Implemented AddWorkerTraceAttributes method in GrpcWorkerChannel to extract worker trace attributes and add them to the current Activity using ExecutionContext.Run

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto Added trace_context field to InvocationResponse message for worker-to-host trace propagation
src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs Added AddWorkerTraceAttributes method to process worker trace attributes and integrated it into the InvokeResponse flow

Comment on lines 1742 to 1758
private void AddWorkerTraceAttributes(InvocationResponse invocationResponse, ScriptInvocationContext context)
{
var attributes = invocationResponse.TraceContext?.Attributes;
if (attributes is null)
{
return;
}

System.Threading.ExecutionContext.Run(context.AsyncExecutionContext, static state =>
{
var attrs = (IDictionary<string, string>)state;
foreach (var kvp in attrs)
{
Activity.Current?.AddTag(kvp.Key, kvp.Value);
}
}, attributes);
}
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

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

The new AddWorkerTraceAttributes functionality lacks test coverage. Consider adding tests similar to the existing SendInvocationRequest_ValidateTraceContext tests (lines 1349-1407 in GrpcWorkerChannelTests.cs) that verify worker trace attributes are properly added to Activity.Current when an InvocationResponse with trace context is received.

Copilot uses AI. Check for mistakes.
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.

[Feature] Add app capabilities feature which provides information on features and attributes of a function app

2 participants