Skip to content

Commit

Permalink
Update TraceProviderSdkTest for legacy activities (#2704)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishweshbankwar authored Nov 29, 2021
1 parent 0c2552e commit 381e0b8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,11 @@ public void SdkSamplesLegacyActivityWithAlwaysOnSampler()
Assert.True(activity.IsAllDataRequested);
Assert.True(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith("-01", activity.Id);

activity.Stop();
}

Expand All @@ -666,6 +671,11 @@ public void SdkSamplesLegacyActivityWithAlwaysOffSampler()
Assert.False(activity.IsAllDataRequested);
Assert.False(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith("-00", activity.Id);

activity.Stop();
}

Expand All @@ -689,6 +699,11 @@ public void SdkSamplesLegacyActivityWithCustomSampler(SamplingDecision samplingD
Assert.Equal(isAllDataRequested, activity.IsAllDataRequested);
Assert.Equal(hasRecordedFlag, activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith(hasRecordedFlag ? "-01" : "-00", activity.Id);

activity.Stop();
}

Expand Down Expand Up @@ -762,6 +777,11 @@ public void SdkSamplesLegacyActivityWithRemoteParentWithCustomSampler(SamplingDe
activity.Start();
Assert.Equal(expectedIsAllDataRequested, activity.IsAllDataRequested);
Assert.Equal(hasRecordedFlag, activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith(hasRecordedFlag ? "-01" : "-00", activity.Id);
activity.Stop();
}

Expand Down Expand Up @@ -792,6 +812,11 @@ public void SdkSamplesLegacyActivityWithRemoteParentWithAlwaysOnSampler(Activity
activity.Start();
Assert.True(activity.IsAllDataRequested);
Assert.True(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith("-01", activity.Id);
activity.Stop();
}

Expand Down Expand Up @@ -822,6 +847,11 @@ public void SdkSamplesLegacyActivityWithRemoteParentWithAlwaysOffSampler(Activit
activity.Start();
Assert.False(activity.IsAllDataRequested);
Assert.False(activity.ActivityTraceFlags.HasFlag(ActivityTraceFlags.Recorded));

// Validating ActivityTraceFlags is not enough as it does not get reflected on
// Id, If the Id is accessed before the sampler runs.
// https://github.com/open-telemetry/opentelemetry-dotnet/issues/2700
Assert.EndsWith("-00", activity.Id);
activity.Stop();
}

Expand Down

0 comments on commit 381e0b8

Please sign in to comment.