Skip to content

Commit

Permalink
Fix Getting default parent span Id with root Parent (#42483)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekgh committed Sep 19, 2020
1 parent 63c3dd1 commit 2269b06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,12 @@ internal static Activity CreateAndStart(ActivitySource source, string name, Acti
else if (parentContext != default)
{
activity._traceId = parentContext.TraceId.ToString();
activity._parentSpanId = parentContext.SpanId.ToString();

if (parentContext.SpanId != default)
{
activity._parentSpanId = parentContext.SpanId.ToString();
}

activity.ActivityTraceFlags = parentContext.TraceFlags;
activity._traceState = parentContext.TraceState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,9 @@ public void TestTraceIdAutoGenerationWithNullParentId()
Assert.NotNull(activity);
Assert.NotEqual(default, ctx);
Assert.Equal(ctx.TraceId, activity.TraceId);
Assert.Equal(ctx.SpanId.ToHexString(), activity.ParentSpanId.ToHexString());
Assert.Equal(default(ActivitySpanId).ToHexString(), ctx.SpanId.ToHexString());
Assert.Equal(ctx.SpanId, activity.ParentSpanId);
Assert.Equal(default(ActivitySpanId), activity.ParentSpanId);
Assert.Equal(default(ActivitySpanId), ctx.SpanId);
}).Dispose();
}

Expand Down

0 comments on commit 2269b06

Please sign in to comment.