diff --git a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs index e0debfd481b..92a1acec8da 100644 --- a/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs +++ b/test/OpenTelemetry.Tests/Trace/TracerProviderSdkTest.cs @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); }