- 
                Notifications
    You must be signed in to change notification settings 
- Fork 841
Description
Description
I am reporting an issue with Microsoft.Extensions.Diagnostics.ResourceMonitoring related to its incompatibility with cgroups v2. This issue is particularly evident when running applications in environments that default to cgroups v2, such as Debian GNU/Linux 12 (Bookworm).
Issue Details
The library seems to be designed to work with cgroups v1, as it attempts to access /sys/fs/cgroup/memory/memory.limit_in_bytes, a path specific to the cgroups v1 hierarchy. In environments using cgroups v2, this path does not exist, leading to System.IO.DirectoryNotFoundException.
Expected Behavior
For environments using cgroups v2, the library should be able to access the appropriate cgroups v2 paths and files to monitor resources.
Actual Behavior
When running in a cgroups v2 environment, the library fails to find the required paths, resulting in an unhandled exception (DirectoryNotFoundException).
Steps to Reproduce
- Run an application using Microsoft.Extensions.Diagnostics.ResourceMonitoringin a Docker container on a system using cgroups v2 (e.g., Debian GNU/Linux 12).
- Observe the DirectoryNotFoundExceptionwhen the library attempts to access cgroups v1 specific paths.
Suggested Solution
It would be beneficial for Microsoft.Extensions.Diagnostics.ResourceMonitoring to include support for cgroups v2, given its increasing adoption in newer Linux distributions.
Additional Context
This issue is crucial for applications that are intended to run in modern Linux environments where cgroups v2 is the default or only available option.