|
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 | using System.Diagnostics; |
| 5 | +using System.Globalization; |
5 | 6 | using Microsoft.Extensions.Configuration; |
6 | 7 | using Microsoft.Extensions.DependencyInjection; |
7 | 8 | using OpenTelemetry.Resources; |
@@ -1055,17 +1056,7 @@ public void SdkPopulatesSamplingParamsCorrectlyForLegacyActivityWithInProcParent |
1055 | 1056 | } |
1056 | 1057 |
|
1057 | 1058 | [Theory] |
1058 | | - [InlineData(null, null, "ParentBased{AlwaysOnSampler}")] |
1059 | | - [InlineData("always_on", null, "AlwaysOnSampler")] |
1060 | | - [InlineData("always_off", null, "AlwaysOffSampler")] |
1061 | | - [InlineData("always_OFF", null, "AlwaysOffSampler")] |
1062 | | - [InlineData("traceidratio", "0.5", "TraceIdRatioBasedSampler{0.500000}")] |
1063 | | - [InlineData("traceidratio", "not_a_double", "TraceIdRatioBasedSampler{1.000000}")] |
1064 | | - [InlineData("parentbased_always_on", null, "ParentBased{AlwaysOnSampler}")] |
1065 | | - [InlineData("parentbased_always_off", null, "ParentBased{AlwaysOffSampler}")] |
1066 | | - [InlineData("parentbased_traceidratio", "0.111", "ParentBased{TraceIdRatioBasedSampler{0.111000}}")] |
1067 | | - [InlineData("parentbased_traceidratio", "not_a_double", "ParentBased{TraceIdRatioBasedSampler{1.000000}}")] |
1068 | | - [InlineData("ParentBased_TraceIdRatio", "0.000001", "ParentBased{TraceIdRatioBasedSampler{0.000001}}")] |
| 1059 | + [ClassData(typeof(SamplerSetConfigurationGenerator))] |
1069 | 1060 | public void TestSamplerSetFromConfiguration(string? configValue, string? argValue, string samplerDescription) |
1070 | 1061 | { |
1071 | 1062 | var configBuilder = new ConfigurationBuilder(); |
@@ -1383,4 +1374,26 @@ public void Dispose() |
1383 | 1374 | this.IsDisposed = true; |
1384 | 1375 | } |
1385 | 1376 | } |
| 1377 | + |
| 1378 | + private sealed class SamplerSetConfigurationGenerator : IEnumerable<object?[]> |
| 1379 | + { |
| 1380 | + private readonly List<object?[]> data = |
| 1381 | + [ |
| 1382 | + [null, null, "ParentBased{AlwaysOnSampler}"], |
| 1383 | + ["always_on", null, "AlwaysOnSampler"], |
| 1384 | + ["always_off", null, "AlwaysOffSampler"], |
| 1385 | + ["always_OFF", null, "AlwaysOffSampler"], |
| 1386 | + ["traceidratio", 0.5.ToString(CultureInfo.CurrentCulture), "TraceIdRatioBasedSampler{0.500000}"], |
| 1387 | + ["traceidratio", "not_a_double", "TraceIdRatioBasedSampler{1.000000}"], |
| 1388 | + ["parentbased_always_on", null, "ParentBased{AlwaysOnSampler}"], |
| 1389 | + ["parentbased_always_off", null, "ParentBased{AlwaysOffSampler}"], |
| 1390 | + ["parentbased_traceidratio", 0.111.ToString(CultureInfo.CurrentCulture), "ParentBased{TraceIdRatioBasedSampler{0.111000}}"], |
| 1391 | + ["parentbased_traceidratio", "not_a_double", "ParentBased{TraceIdRatioBasedSampler{1.000000}}"], |
| 1392 | + ["ParentBased_TraceIdRatio", 0.000001.ToString(CultureInfo.CurrentCulture), "ParentBased{TraceIdRatioBasedSampler{0.000001}}"], |
| 1393 | + ]; |
| 1394 | + |
| 1395 | + public IEnumerator<object[]> GetEnumerator() => this.data.GetEnumerator(); |
| 1396 | + |
| 1397 | + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => this.GetEnumerator(); |
| 1398 | + } |
1386 | 1399 | } |
0 commit comments