You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationParserCgroupV1.cs
+1-1
Original file line number
Diff line number
Diff line change
@@ -145,7 +145,7 @@ public long GetHostCpuUsageInNanoseconds()
145
145
$"'{_procStat}' should contain whitespace separated values according to POSIX. We've failed trying to get {i}th value. File content: '{newstring(stat)}'.");
Copy file name to clipboardexpand all lines: src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationParserCgroupV2.cs
+1-1
Original file line number
Diff line number
Diff line change
@@ -163,7 +163,7 @@ public long GetHostCpuUsageInNanoseconds()
163
163
$"'{_procStat}' should contain whitespace separated values according to POSIX. We've failed trying to get {i}th value. File content: '{newstring(stat)}'.");
#pragma warning restore CA2000// Dispose objects before losing scope
67
69
70
+
_=meter.CreateObservableCounter(name:ResourceUtilizationInstruments.ContainerCpuTime,observeValues:GetCpuTime,unit:"s",description:"CPU time used by the container.");
Copy file name to clipboardexpand all lines: src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsContainerSnapshotProvider.cs
+12
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
// The .NET Foundation licenses this file to you under the MIT license.
#pragma warning restore CA2000// Dispose objects before losing scope
110
112
111
113
// Container based metrics:
114
+
_=meter.CreateObservableCounter(name:ResourceUtilizationInstruments.ContainerCpuTime,observeValues:GetCpuTime,unit:"s",description:"CPU time used by the container.");
Copy file name to clipboardexpand all lines: test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
+8-2
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ public void Provider_Registers_Instruments()
74
74
listener.Start();
75
75
listener.RecordObservableInstruments();
76
76
77
-
Assert.Equal(5,samples.Count);
77
+
Assert.Equal(7,samples.Count);
78
78
79
79
Assert.Contains(samples, x =>x.instrument.Name==ResourceUtilizationInstruments.ContainerCpuLimitUtilization);
Copy file name to clipboardexpand all lines: test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs
+60
Original file line number
Diff line number
Diff line change
@@ -190,6 +190,66 @@ public void GetSnapshot_With_JobMemoryLimit_Set_To_Zero_ProducesCorrectSnapshot(
190
190
Assert.True(data.MemoryUsageInBytes>0);
191
191
}
192
192
193
+
[Fact]
194
+
publicvoidSnapshotProvider_EmitsCpuTimeMetric()
195
+
{
196
+
// Simulating 10% CPU usage (2 CPUs, 2000 ticks initially, 4000 ticks after 1 ms):
0 commit comments