Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ internal async Task InvokeResponse(InvocationResponse invokeResponse)
}

LogSharedMemoryUsage(invokeResponse);
AddWorkerTraceAttributes(invokeResponse, context);

if (invokeResponse.Result.IsInvocationSuccess())
{
Expand Down Expand Up @@ -1738,6 +1739,29 @@ private void AddAdditionalTraceContext(InvocationRequest invocationRequest, Scri
}
}

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

if (context.AsyncExecutionContext is null)
{
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

{
var attrs = (IDictionary<string, string>)state;
foreach (var kvp in attrs)
{
Activity.Current?.AddTag(kvp.Key, kvp.Value);
}
}, attributes);
}

private sealed class ExecutingInvocation : IDisposable
{
public ExecutingInvocation(ScriptInvocationContext context, IInvocationMessageDispatcher dispatcher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ message InvocationResponse {

// 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

}

message WorkerWarmupRequest {
Expand Down