diff --git a/test/IntegrationTests/ContinuousProfilerTests.cs b/test/IntegrationTests/ContinuousProfilerTests.cs index 088982e2ba..17c737971a 100644 --- a/test/IntegrationTests/ContinuousProfilerTests.cs +++ b/test/IntegrationTests/ContinuousProfilerTests.cs @@ -3,6 +3,7 @@ #if NET +using FluentAssertions; using IntegrationTests.Helpers; using OpenTelemetry.Proto.Collector.Profiles.V1Development; using OpenTelemetry.Proto.Profiles.V1Development; @@ -46,7 +47,7 @@ public void ExportThreadSamples() SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler"); var expectedStackTrace = string.Join("\n", CreateExpectedStackTrace()); - collector.ExpectCollected(AllLocationReferencesProfileFrameTypeAttribute, "All location should contain reference to profile.frame.type attribute"); + collector.ExpectCollected(ExpectCollected, "Expect Collected failed"); collector.Expect(profileData => profileData.ResourceProfiles.Any(resourceProfiles => resourceProfiles.ScopeProfiles.Any(scopeProfile => scopeProfile.Profiles.Any(profile => ContainStackTraceForClassHierarchy(profile, expectedStackTrace) && ContainAttributes(profile, "cpu"))))); collector.ResourceExpector.Expect("todo.resource.detector.key", "todo.resource.detector.value"); @@ -57,11 +58,14 @@ public void ExportThreadSamples() collector.ResourceExpector.AssertExpectations(); } - private static bool AllLocationReferencesProfileFrameTypeAttribute(ICollection c) + private static bool ExpectCollected(ICollection c) { - var profiles = c.SelectMany(r => r.ResourceProfiles) - .SelectMany(rp => rp.ScopeProfiles) - .SelectMany(sp => sp.Profiles).ToList(); + var scopeProfiles = c.SelectMany(r => r.ResourceProfiles) + .SelectMany(rp => rp.ScopeProfiles).ToList(); + + scopeProfiles.Should().AllSatisfy(sp => sp.Scope.Name.Should().Be("OpenTelemetry.AutoInstrumentation")); + + var profiles = scopeProfiles.SelectMany(sp => sp.Profiles).ToList(); foreach (var profile in profiles) { diff --git a/test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/OtlpOverHttpExporter.cs b/test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/OtlpOverHttpExporter.cs index 1709f0f3aa..32f926565d 100644 --- a/test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/OtlpOverHttpExporter.cs +++ b/test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/OtlpOverHttpExporter.cs @@ -177,6 +177,12 @@ private static ResourceProfiles CreateResourceProfiles(ScopeProfiles scopeProfil private static ScopeProfiles CreateScopeProfiles() { var scopeProfiles = new ScopeProfiles(); + scopeProfiles.Scope = new InstrumentationScope + { + Name = "OpenTelemetry.AutoInstrumentation", + // TODO consider setting Version here + }; + // TODO handle schema Url scopeProfiles.SchemaUrl return scopeProfiles;