powersupply: standardize units to SI base units (#1817)#3611
Open
Pittu-Sharma wants to merge 6 commits intoprometheus:masterfrom
Open
powersupply: standardize units to SI base units (#1817)#3611Pittu-Sharma wants to merge 6 commits intoprometheus:masterfrom
Pittu-Sharma wants to merge 6 commits intoprometheus:masterfrom
Conversation
This adds a tool to statically analyze collectors and generate a comprehensive metrics list in docs/METRICS.md. This ensures the documentation remains accurate and maintainable. Signed-off-by: pittu sharma <pittusharma47@gmail.com>
Signed-off-by: pittu sharma <pittusharma47@gmail.com>
…h separators, and adding DCO sign-off Signed-off-by: pittu sharma <pittusharma47@gmail.com>
Signed-off-by: pittu sharma <pittusharma47@gmail.com>
Signed-off-by: pittu sharma <pittusharma47@gmail.com>
This change implements SI base unit standardization for power supply metrics as requested in issue prometheus#1817. - Adds --collector.powersupply.use-new-names flag for dual-exposure. - Normalizes voltage (V), current (A), energy (J), charge (C), and power (W) to base units across Linux and Darwin. - Updates documentation and removes informal comments. - Purged irrelevant files from the workspace to ensure logical completeness. Signed-off-by: pittu sharma <pittusharma47@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This Pull Request addresses issue #1817 by standardizing the powersupplyclass collector metrics to follow Prometheus' SI base unit guidelines.
Currently, the collector exports metrics in kernel-native micro-units (e.g., current_now in$\mu A$ ) and has naming inconsistencies between Linux and Darwin platforms. This change introduces a modernization path that:
Standardizes Units: Normalizes Current ($\mu A$ -> $A$ ), Voltage ($\mu V$ -> $V$ ), Energy ($\mu Wh$ -> $J$ ), Charge ($\mu Ah$ -> $C$ ), and Capacity ($%$ -> $Ratio$ ).
Unifies Naming: Ensures consistent suffix-based names (e.g., _amperes, _volts, _joules) across both supported platforms.
Maintains Compatibility: Uses a new feature flag --collector.powersupply.use-new-names to dual-expose corrected metrics while keeping legacy names as the default.
Key Changes:
Collector Flag: Added collector.powersupply.use-new-names (defaults to false).
Linux (powersupplyclass_linux.go): Refactored metric mapping to catch all power-related fields using robust prefix/contains logic and applied SI scaling factors.
Darwin (powersupplyclass_darwin.go): Implemented matching scale factors for IOKit data and added node_power_supply_capacity_ratio for parity with Linux.
Documentation: Updated docs/collectors/powersupplyclass.md with details on the new metrics and flag.