|
4 | 4 | #if NET |
5 | 5 |
|
6 | 6 | using IntegrationTests.Helpers; |
| 7 | +using OpenTelemetry.Proto.Collector.Profiles.V1Development; |
7 | 8 | using OpenTelemetry.Proto.Profiles.V1Development; |
8 | 9 | using Xunit.Abstractions; |
9 | 10 |
|
@@ -43,17 +44,39 @@ public void ExportThreadSamples() |
43 | 44 | SetExporter(collector); |
44 | 45 | SetEnvironmentVariable("OTEL_DOTNET_AUTO_PLUGINS", "TestApplication.ContinuousProfiler.ThreadPlugin, TestApplication.ContinuousProfiler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); |
45 | 46 | SetEnvironmentVariable("OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES", "TestApplication.ContinuousProfiler"); |
46 | | - RunTestApplication(); |
47 | | - |
48 | 47 | var expectedStackTrace = string.Join("\n", CreateExpectedStackTrace()); |
49 | 48 |
|
| 49 | + collector.ExpectCollected(AllLocationReferencesProfileFrameTypeAttribute, "All location should contain reference to profile.frame.type attribute"); |
50 | 50 | collector.Expect(profileData => profileData.ResourceProfiles.Any(resourceProfiles => resourceProfiles.ScopeProfiles.Any(scopeProfile => scopeProfile.Profiles.Any(profile => ContainStackTraceForClassHierarchy(profile, expectedStackTrace) && ContainAttributes(profile, "cpu"))))); |
51 | 51 | collector.ResourceExpector.Expect("todo.resource.detector.key", "todo.resource.detector.value"); |
52 | 52 |
|
| 53 | + RunTestApplication(); |
| 54 | + |
| 55 | + collector.AssertCollected(); |
53 | 56 | collector.AssertExpectations(); |
54 | 57 | collector.ResourceExpector.AssertExpectations(); |
55 | 58 | } |
56 | 59 |
|
| 60 | + private static bool AllLocationReferencesProfileFrameTypeAttribute(ICollection<ExportProfilesServiceRequest> c) |
| 61 | + { |
| 62 | + var profiles = c.SelectMany(r => r.ResourceProfiles) |
| 63 | + .SelectMany(rp => rp.ScopeProfiles) |
| 64 | + .SelectMany(sp => sp.Profiles).ToList(); |
| 65 | + |
| 66 | + foreach (var profile in profiles) |
| 67 | + { |
| 68 | + var attributeTable = profile.AttributeTable; |
| 69 | + |
| 70 | + var attributeIndices = profiles.SelectMany(p => p.LocationTable).Select(l => l.AttributeIndices.Single()); |
| 71 | + if (!attributeIndices.All(index => attributeTable[index] is { Key: "profile.frame.type" })) |
| 72 | + { |
| 73 | + return false; |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + return true; |
| 78 | + } |
| 79 | + |
57 | 80 | private static bool ContainAttributes(Profile profileContainer, string profilingDataType) |
58 | 81 | { |
59 | 82 | return profileContainer.AttributeTable.Any(x => x.Key == "todo.profiling.data.type" && x.Value.StringValue == profilingDataType); |
|
0 commit comments