Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gRPC span and correlate client and orchestrator functions for DF .NET Isolated Distributed Tracing #2998

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata.Ecma335;
using System.Threading;
Expand Down Expand Up @@ -154,8 +155,22 @@
{
try
{
ActivitySource activityTraceSource = new ActivitySource("DurableTask.WebJobs");
Copy link
Collaborator Author

@bachuv bachuv Dec 17, 2024

Choose a reason for hiding this comment

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

For context, the source name is "DurableTask.WebJobs" because we load the DurableTelemetryModule and it looks for sources that start with "DurableTask" (related code link). I'm working on updating the listeners to add a new one ("WebJobs.Extensions.DurableTask") when we initialize the module so we can remove this "DurableTask.WebJobs" that's just used to test for now.


Activity? newActivity = activityTraceSource.CreateActivity("gRPC start orchestration", kind: ActivityKind.Server);

if (newActivity != null)
{
newActivity.SetParentId(request.ParentTraceContext.TraceParent);

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / build

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 164 in src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'CreateInstanceRequest' does not contain a definition for 'ParentTraceContext' and no accessible extension method 'ParentTraceContext' accepting a first argument of type 'CreateInstanceRequest' could be found (are you missing a using directive or an assembly reference?)
}

newActivity?.Start();

string instanceId = await this.GetClient(context).StartNewAsync(
request.Name, request.InstanceId, Raw(request.Input));

newActivity?.Stop();

return new P.CreateInstanceResponse
{
InstanceId = instanceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.DurableTask;
Expand Down Expand Up @@ -76,6 +77,12 @@
StartOrchestrationOptions? options = null,
CancellationToken cancellation = default)
{
Activity? currActivity = Activity.Current;
if (options == null && options?.ParentTraceId == null && currActivity != null)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 81 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'StartOrchestrationOptions' does not contain a definition for 'ParentTraceId' and no accessible extension method 'ParentTraceId' accepting a first argument of type 'StartOrchestrationOptions' could be found (are you missing a using directive or an assembly reference?)
{
options = new StartOrchestrationOptions(ParentTraceId: currActivity?.Id?.ToString());

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'

Check failure on line 83 in src/Worker.Extensions.DurableTask/FunctionsDurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The best overload for 'StartOrchestrationOptions' does not have a parameter named 'ParentTraceId'
}
Comment on lines +80 to +84
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the ParentTraceId information to the StartOrchestrationOptions, but I'm wondering if there's a better place to store this information since StartOrchestrationOptions can be configured by the customer and we don't necessarily need customers to have access to ParentTraceId.


return this.inner.ScheduleNewOrchestrationInstanceAsync(orchestratorName, input, options, cancellation);
}

Expand Down
Loading