-
Notifications
You must be signed in to change notification settings - Fork 831
Add memory usage metric #6586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add memory usage metric #6586
Conversation
6989b03
to
d671e88
Compare
9779fd3
to
dd6b70f
Compare
ac948f7
to
120a012
Compare
2b4b3ed
to
66a792d
Compare
66a792d
to
e06592f
Compare
e06592f
to
244d332
Compare
244d332
to
412064a
Compare
...rosoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsContainerSnapshotProvider.cs
Show resolved
Hide resolved
.../Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
Outdated
Show resolved
Hide resolved
.../Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
Outdated
Show resolved
Hide resolved
.../Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/AcceptanceTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new container.memory.usage
metric (bytes) as an ObservableUpDownCounter across Windows and Linux, updates logging, and extends tests to validate the new instrument.
- Introduce
ContainerMemoryUsage
constant and register it in both Windows and Linux providers. - Refactor snapshot providers to expose container memory usage and separate percentage calculations, updating log messages.
- Extend unit and acceptance tests to subscribe to and assert on the new memory‐usage metric.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/.../Windows/WindowsContainerSnapshotProviderTests.cs | Added tests for combined container/process memory metrics and standalone usage test |
test/.../Linux/LinuxUtilizationProviderTests.cs | Captured ContainerMemoryUsage in measurements, updated expected sample/retry counts |
test/.../Linux/AcceptanceTest.cs | Subscribed to and asserted on new container memory usage gauge |
test/.../ResourceUtilizationHealthChecks/ResourceHealthCheckExtensionsTests.cs | Added GetCurrentProcessMemoryUsage setup for health‐check tests |
src/Shared/Instruments/ResourceUtilizationInstruments.cs | Added public const string ContainerMemoryUsage constant with XML docs |
src/Libraries/.../Windows/WindowsSnapshotProvider.cs | Refactored memory methods, added _processMemoryLocker , new up/down counter, log rename |
src/Libraries/.../Windows/Log.cs | Added ContainerMemoryUsageData and ProcessMemoryPercentageData messages |
src/Libraries/.../Linux/Log.cs | Renamed MemoryUsageData to MemoryPercentageData , added new MemoryUsageData |
src/Libraries/.../Linux/LinuxUtilizationProvider.cs | Refactored memory methods, added up/down counter for usage, updated retry helper |
Comments suppressed due to low confidence (2)
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsContainerSnapshotProvider.cs:234
- Logging while holding the _memoryLocker can lead to lock contention or unexpected delays. It’s safer to capture the values inside the lock and invoke the logger after releasing the lock to minimize the duration of the critical section.
_logger.ProcessMemoryPercentageData(processMemoryUsage, _memoryLimit, _processMemoryPercentage);
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Log.cs:69
- The
totalMemory
parameter represents a byte count but is typed asdouble
. For consistency withprocessMemoryUsage
and to avoid implicit conversions, consider changingtotalMemory
toulong
.
double memoryPercentage);
Fixes #6587
Microsoft Reviewers: Open in CodeFlow
Adding
container.memory.usage
metric withObservableUpDownCounter
instrument type, measured in bytes.