fix(collector): keep collecting temperatures without CPU power status - #3767
fix(collector): keep collecting temperatures without CPU power status#3767SaiPisey2 wants to merge 2 commits into
Conversation
|
/workflow-approve |
|
The Darwin/macOS e2e job is failing on a fixture mismatch, Then commit the updated |
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>
8d1e633 to
907bf2f
Compare
|
Thanks for the review. Pushed, but regenerating the fixture turned up two things worth flagging rather than just committing the output. The fixture change itself I did not commit a regenerated file. Running
Worth knowing before anyone else follows the same instruction. The Darwin fixture path is built with I also added (Unrelated and left alone: the A real bug the fixture regeneration exposed This is the part I would not have caught otherwise. Once temperatures are actually collected, the collector emits duplicate label sets: and the scrape logs A sensor is identified only by its IOHID Since there is no property that makes them addressable, I report the first reading per name and count the rest in a debug line. The endpoint now returns 200 with 17 unique series and no gather errors. CI never sees this, since the runner has no sensors, but every Apple Silicon machine would have. Verified locally: Happy to split the two |
|
Thanks for the fixes. Let's split the On the duplicate sensors: dropping readings loses data. #3646 hit the same colliding-label problem for hwmon and fixed it by disambiguating the label instead (suffix it, falling back to something always unique when the first suffix still collides). Take a look there for the approach. |
Collecting temperatures on Apple Silicon surfaced a second problem that was previously unreachable, because Update returned before updateTemperatures ever ran. A sensor is labelled with its IOHID "Product" property, which is not unique. On an M5 Pro, 52 temperature-reporting services carry only 17 distinct product names, so the registry rejects the colliding samples and logs an error on every scrape. The collisions are of two kinds. Six "gas gauge battery" services are distinct sensors that merely share a name; they have distinct LocationIDs. The "PMU tdie*" services come in threes that share both the name and the LocationID, and report readings that differ by a few tenths of a degree, so they are separate sensing elements rather than the same one listed repeatedly. Dropping either kind loses readings. Following the approach taken for hwmon in prometheus#3646, read all sensors first, then qualify a name shared by several services with its location, falling back to the service registry ID when the location does not separate them either. Registry IDs are unique per service, which the OS guarantees and which held for every service observed here. Names that do not collide are left untouched. The endpoint now reports all 52 readings with unique label sets and no gather errors, where before the change 35 of them were rejected. Also update collector/fixtures/e2e-output-darwin.txt for node_scrape_collector_success{collector="thermal"}, which is now 1 because the collector no longer fails. resolveSensorNames is kept free of cgo so that the labelling rules are covered by table-driven tests, which matters because the CI runner reports no thermal sensors at all. Signed-off-by: SaiPisey2 <piseysai0202@gmail.com>
907bf2f to
1d0ecba
Compare
|
Both done. The You were right that dropping loses data — more than I realised before looking properly. Probing the services directly, the collisions turn out to be two different things:
So both kinds carry real readings, and the earlier "first one wins" would have thrown away 35 of 52. Following #3646: read all sensors first, then qualify a colliding name with its location, falling back to the registry ID when the location does not separate them either. Names that do not collide are untouched.
Result on the same machine, where before the change 35 of 52 samples were rejected: One deliberate choice worth flagging: the label resolution lives in Registry IDs are not stable across reboots, so those labels will change if the machine restarts. That is the same trade-off as the Verified: |
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/