Skip to content

Commit

Permalink
Merge branch 'main' into testcoverage_InMemoryExporterDeferred
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas authored Jun 9, 2022
2 parents f422038 + c079179 commit 2e7150e
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ public void ToOtlpResourceSpansTest(bool includeServiceNameInResource)
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++)
Expand All @@ -161,8 +161,7 @@ public void ToOtlpResourceSpansTest(bool includeServiceNameInResource)
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);

Expand All @@ -184,7 +183,9 @@ void RunTest(Batch<Activity> batch)
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);
Expand Down

0 comments on commit 2e7150e

Please sign in to comment.