Skip to content

Commit

Permalink
Activity ParentSpanId check fix for Rc2 (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Oct 16, 2020
1 parent 2786809 commit b415b8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,8 @@ internal static OtlpTrace.Span ToOtlpSpan(this Activity activity)
activity.SpanId.CopyTo(spanIdBytes);

var parentSpanIdString = ByteString.Empty;
if (activity.ParentSpanId.ToHexString() != EmptyActivitySpanId)
if (activity.ParentSpanId != default)
{
// TODO: Once .NET fixes this https://github.com/dotnet/runtime/issues/42456
// and Otel updates to the version containing the fix,
// the above check can be simplified to
// if (activity.ParentSpanId != default)
Span<byte> parentSpanIdBytes = stackalloc byte[8];
activity.ParentSpanId.CopyTo(parentSpanIdBytes);
parentSpanIdString = ByteString.CopyFrom(parentSpanIdBytes.ToArray());
Expand Down
5 changes: 1 addition & 4 deletions test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ public void TracerProviderSdkInvokesSamplingWithCorrectParameters()
using (var rootActivity = activitySource.StartActivity("root"))
{
Assert.NotNull(rootActivity);

// Known issue: https://github.com/dotnet/runtime/issues/42456
// hence rootActivity.ParentSpanId == default, may not be true.
Assert.True(rootActivity.ParentSpanId == default || rootActivity.ParentSpanId.ToHexString() == default(ActivitySpanId).ToHexString());
Assert.True(rootActivity.ParentSpanId == default);

// Validate that the TraceId seen by Sampler is same as the
// Activity when it got created.
Expand Down

0 comments on commit b415b8a

Please sign in to comment.