Skip to content

Add scaling to [0, 100] for LinuxUtilizationProvider#7289

Open
amadeuszl wants to merge 6 commits intodotnet:mainfrom
amadeuszl:users/alechniak/fix-0-100-linux-utilization
Open

Add scaling to [0, 100] for LinuxUtilizationProvider#7289
amadeuszl wants to merge 6 commits intodotnet:mainfrom
amadeuszl:users/alechniak/fix-0-100-linux-utilization

Conversation

@amadeuszl
Copy link
Contributor

@amadeuszl amadeuszl commented Feb 12, 2026

Fix #7124

Microsoft Reviewers: Open in CodeFlow

@amadeuszl amadeuszl requested a review from a team as a code owner February 12, 2026 12:26
Copilot AI review requested due to automatic review settings February 12, 2026 12:26
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 addresses #7124 by adding a Linux-specific option to emit CPU/memory utilization metrics either as ratios ([0,1]) or as percentage-like values ([0,100]) to support exporters that don’t handle fractional values well.

Changes:

  • Added ResourceMonitoringOptions.UseZeroToOneRangeForLinuxMetrics (defaulting to [0,1] behavior).
  • Updated LinuxUtilizationProvider to apply a configurable multiplier (1 or 100) to Linux CPU and memory utilization metric calculations.
  • Added Linux utilization provider tests to validate the new scaling behavior (currently focused on memory utilization).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
test/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs Adds tests for the new Linux scaling option (memory utilization assertions).
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs Introduces the new Linux-specific scaling option with XML docs.
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationProvider.cs Applies the scaling option to CPU/memory utilization metric calculations via a multiplier.

/// Use this property if you prefer to have the metric values in range <c>[0, 100]</c> instead of <c>[0, 1]</c>.
/// </remarks>
[Experimental(diagnosticId: DiagnosticIds.Experiments.ResourceMonitoring, UrlFormat = DiagnosticIds.UrlFormat)]
public bool UseZeroToOneRangeForLinuxMetrics { get; set; } = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For windows we have UseZeroToOneRangeForMetrics where it's false by default, It's a bit ugly, but that's where we are to not cause breaking changes.

We can make behavior breaking change and use only one option UseZeroToOneRangeForMetrics, set to true bu default. I think we even should make it before going to API review, as this state of things made not go through the review.

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.

Linux Resource Monitoring has no option to emit values [0,100]

1 participant