Skip to content

powersupply: standardize units to SI base units (#1817)#3611

Open
Pittu-Sharma wants to merge 6 commits intoprometheus:masterfrom
Pittu-Sharma:fix/powersupply-si-units-1817
Open

powersupply: standardize units to SI base units (#1817)#3611
Pittu-Sharma wants to merge 6 commits intoprometheus:masterfrom
Pittu-Sharma:fix/powersupply-si-units-1817

Conversation

@Pittu-Sharma
Copy link
Copy Markdown

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant