Skip to content

Commit bee3cb8

Browse files
authored
Add parent trace context information when scheduling an orchestration (#358)
1 parent bbe82f9 commit bee3cb8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Client/Grpc/GrpcDurableTaskClient.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using System.Diagnostics;
45
using System.Text;
56
using Google.Protobuf.WellKnownTypes;
67
using Microsoft.DurableTask.Client.Entities;
@@ -85,6 +86,24 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
8586
Input = this.DataConverter.Serialize(input),
8687
};
8788

89+
if (Activity.Current?.Id != null || Activity.Current?.TraceStateString != null)
90+
{
91+
if (request.ParentTraceContext == null)
92+
{
93+
request.ParentTraceContext = new P.TraceContext();
94+
}
95+
96+
if (Activity.Current?.Id != null)
97+
{
98+
request.ParentTraceContext.TraceParent = Activity.Current?.Id;
99+
}
100+
101+
if (Activity.Current?.TraceStateString != null)
102+
{
103+
request.ParentTraceContext.TraceState = Activity.Current?.TraceStateString;
104+
}
105+
}
106+
88107
DateTimeOffset? startAt = options?.StartAt;
89108
this.logger.SchedulingOrchestration(
90109
request.InstanceId,

0 commit comments

Comments
 (0)