fix(collector): keep collecting temperatures without CPU power status - #3767
Open
SaiPisey2 wants to merge 1 commit into
Open
fix(collector): keep collecting temperatures without CPU power status#3767SaiPisey2 wants to merge 1 commit into
SaiPisey2 wants to merge 1 commit into
Conversation
Apple Silicon does not implement IOPMCopyCPUPowerStatus, so fetchCPUPowerStatus returns kIOReturnNotFound there. Update returned that error straight away, which aborted the collector before updateTemperatures ran, so no temperature metrics were collected at all. The error was also not ErrNoData, so it was logged at error level on every scrape. On an M5 Pro, Update emitted 0 metrics and failed, while updateTemperatures on its own returned 52 temperature metrics. Treat kIOReturnNotFound as a system that does not report CPU power status: skip the three CPU power metrics, log at debug level and carry on to the temperature sensors. Any other non-success return code is still returned as an error. Systems that do report CPU power status are unaffected. This does not make the CPU power metrics available on Apple Silicon, since the underlying API provides no data. It only stops their absence from suppressing the temperature metrics. Adds a regression test covering the case. Signed-off-by: SaiPisey2 <piseysai0202@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.
Addresses #2906.
Apple Silicon does not implement
IOPMCopyCPUPowerStatus, sofetchCPUPowerStatusgets backkIOReturnNotFound.Updatereturned that error straight away, which meant it never reachedupdateTemperatures, so no temperature metrics were collected at all. The error also isn'tErrNoData, so it was logged at error level on every scrape.Measured on an M5 Pro (darwin/arm64) against master:
52 usable temperature sensors on that machine, none of them exported, because an expected and unrelated condition aborted the collector.
Change
Treat
kIOReturnNotFoundas "this system does not report CPU power status" rather than a failure: skip the three CPU power metrics, log at debug level, and continue on to the temperature sensors. Any other non-success return code is still returned as an error, exactly as before, so systems that do report CPU power status are unaffected.After the change, on the same machine,
Update()returns no error and emits all 52 temperature metrics.Scope
This does not make the CPU power metrics appear on Apple Silicon and does not resolve #2218 — the underlying API provides no data there, as @rexagod already established on #2906. It only stops their absence from suppressing the temperature metrics. I've left
Closes #2906out of the commit deliberately, since whether that issue is fully answered by this is a maintainer call.Testing
Added
collector/thermal_darwin_test.go, which fails on master:and passes with the change. Also verified locally:
go build ./...go vet ./collector/gofmt -lclean on both touched filesgo test ./collector/full packagego build -tags notherm ./collector/