Add scaling to [0, 100] for LinuxUtilizationProvider#7289
Add scaling to [0, 100] for LinuxUtilizationProvider#7289amadeuszl wants to merge 6 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
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
LinuxUtilizationProviderto 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. |
...osoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
Show resolved
Hide resolved
...osoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
Show resolved
Hide resolved
...osoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
Show resolved
Hide resolved
...osoft.Extensions.Diagnostics.ResourceMonitoring.Tests/Linux/LinuxUtilizationProviderTests.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs
Show resolved
Hide resolved
| /// 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; |
There was a problem hiding this comment.
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.
Fix #7124
Microsoft Reviewers: Open in CodeFlow