Skip to content

Conversation

@amadeuszl
Copy link
Contributor

@amadeuszl amadeuszl commented Nov 24, 2025

Second part of addressing #6496

Microsoft Reviewers: Open in CodeFlow

@amadeuszl amadeuszl requested a review from a team as a code owner November 24, 2025 21:00
Copilot AI review requested due to automatic review settings November 24, 2025 21:00
@amadeuszl amadeuszl requested a review from a team as a code owner November 24, 2025 21:00
@amadeuszl amadeuszl linked an issue Nov 24, 2025 that may be closed by this pull request
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds metering for baseline resource quotas (CPU and memory request utilization) in the resource monitoring library. The implementation provides new observable gauge metrics that track resource consumption relative to baseline/requested allocations (as opposed to the existing limit-based metrics), which is particularly useful for Kubernetes environments where requests represent guaranteed minimum resources.

Key Changes

  • Added ContainerCpuRequestUtilization and ContainerMemoryRequestUtilization instrument constants
  • Implemented CPU and memory request utilization metrics in both Windows and Linux resource monitoring providers
  • Updated logging methods to distinguish between limit and request utilization calculations
  • Extended test coverage to validate the new request-based metrics

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Shared/Instruments/ResourceUtilizationInstruments.cs Added two new instrument constant definitions for CPU and memory request utilization metrics
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsContainerSnapshotProvider.cs Implemented request utilization gauges, refactored CpuPercentage to accept denominator parameter, changed _memoryRequest field type from ulong to double, and improved precision by using original quota values instead of rounded doubles
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Log.cs Updated ContainerMemoryUsageData logging method to include both limit and request memory values
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationProvider.cs Added ContainerMemoryRequestUtilization gauge, split MemoryPercentage into separate MemoryPercentageLimit and MemoryPercentageRequest methods, changed _memoryRequest field type from ulong to double, and improved precision by using original quota values
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Log.cs Renamed MemoryPercentageData to MemoryPercentageLimit and added new MemoryPercentageRequest logging method for request-based utilization
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Windows/WindowsContainerSnapshotProviderTests.cs Extended test coverage with InlineData test cases for CPU and memory request utilization metrics
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs Updated test to reflect the addition of ContainerMemoryRequestUtilization metric (increased expected call count from 3 to 4)

… bug with emitting metrics without wall time passing on Linux
This was referenced Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Kubernetes specialized Resource Monitoring

2 participants