Skip to content

Commit 22a98ee

Browse files
committed
added null check for ParentTraceContext
1 parent 82a6717 commit 22a98ee

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Client/Grpc/GrpcDurableTaskClient.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,22 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
8686
Input = this.DataConverter.Serialize(input),
8787
};
8888

89-
if (Activity.Current?.Id != null)
89+
if (Activity.Current?.Id != null || Activity.Current?.TraceStateString != null)
9090
{
91-
request.ParentTraceContext.TraceParent = Activity.Current?.Id;
92-
}
91+
if (request.ParentTraceContext == null)
92+
{
93+
request.ParentTraceContext = new P.TraceContext();
94+
}
9395

94-
if (Activity.Current?.TraceStateString != null)
95-
{
96-
request.ParentTraceContext.TraceState = Activity.Current?.TraceStateString;
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+
}
97105
}
98106

99107
DateTimeOffset? startAt = options?.StartAt;

0 commit comments

Comments
 (0)