Fix OTLP test (#3357)
* Show that test is not doing what you might think it does * More asserts the merrier * Show this little test that it has potential
This commit is contained in:
parent
91d7e83f23
commit
c07917913c
|
|
@ -140,15 +140,15 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
resourceBuilder.AddService("service-name", "ns1");
|
||||
}
|
||||
|
||||
var exportedItems = new List<Activity>();
|
||||
var builder = Sdk.CreateTracerProviderBuilder()
|
||||
.SetResourceBuilder(resourceBuilder)
|
||||
.AddSource(sources[0].Name)
|
||||
.AddSource(sources[1].Name);
|
||||
.AddSource(sources[1].Name)
|
||||
.AddProcessor(new SimpleActivityExportProcessor(new InMemoryExporter<Activity>(exportedItems)));
|
||||
|
||||
using var openTelemetrySdk = builder.Build();
|
||||
|
||||
var exportedItems = new List<Activity>();
|
||||
var processor = new BatchActivityExportProcessor(new InMemoryExporter<Activity>(exportedItems));
|
||||
const int numOfSpans = 10;
|
||||
bool isEven;
|
||||
for (var i = 0; i < numOfSpans; i++)
|
||||
|
|
@ -161,8 +161,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
using Activity activity = source.StartActivity($"span-{i}", activityKind, parentContext: default, activityTags);
|
||||
}
|
||||
|
||||
processor.Shutdown();
|
||||
|
||||
Assert.Equal(10, exportedItems.Count);
|
||||
var batch = new Batch<Activity>(exportedItems.ToArray(), exportedItems.Count);
|
||||
RunTest(batch);
|
||||
|
||||
|
|
@ -184,7 +183,9 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
Assert.Contains(otlpResource.Attributes, (kvp) => kvp.Key == ResourceSemanticConventions.AttributeServiceName && kvp.Value.ToString().Contains("unknown_service:"));
|
||||
}
|
||||
|
||||
foreach (var scope in request.ResourceSpans.First().ScopeSpans)
|
||||
var scopeSpans = request.ResourceSpans.First().ScopeSpans;
|
||||
Assert.Equal(2, scopeSpans.Count);
|
||||
foreach (var scope in scopeSpans)
|
||||
{
|
||||
Assert.Equal(numOfSpans / 2, scope.Spans.Count);
|
||||
Assert.NotNull(scope.Scope);
|
||||
|
|
|
|||
Loading…
Reference in New Issue