Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TraceProviderSdkTest for legacy activities #2704

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);
vishweshbankwar marked this conversation as resolved.
Show resolved Hide resolved

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