Sanitize strings from /sys/class/power_supply#1984
Conversation
|
CC @hhoffstaette, could you give this patch a try? |
966849a to
723e9d9
Compare
|
Ok, so I am not liking the simple sanitize by dropping invalid runes. I'm going to figure out a better string sanitizer. |
Why not? There is IMHO no other good way to handle this. Replacing them with other characters ('X' or '?') is bound to be misleading, and they are not likely to appear in the middle of the name. |
|
What I would like is to replace the letters with something like |
🤔 having escaped characters in the string is IMHO not helpful. I'd rather just have the value reduced to ASCII (printable characters) and be done, I don't see why this needs to be more complicated than necessary; remember that this will almost never trigger anyway. |
|
When I fix the patch to use ..works for me? ¯\_(ツ)_/¯ |
|
Yea, I suppose. My usual preference is to preserve as much data as possible. I dislike silently eating data. |
723e9d9 to
d197a2f
Compare
|
That's weird, this shouldn't impact the scrape duration that much. Is that for |
I deleted my comment. The picture showed the complete scrape time (up by ~50ms), but then I realized that the additional time was caused by the powersupply class collector (regardless of sanitizing). procfs/sysfs values are pulled on-demand and talking to the HW (in this case reading voltages etc. from the battery/sensors via ACPI and whatnot) is just slow. |
d197a2f to
6deb047
Compare
Avoid panic on invalid UTF-8 from /sys/class/power_supply by sanitizing strings parsed from the kernel. * Add a broken string to the test fixtures. Fixes: #1979 Signed-off-by: Ben Kochie <superq@gmail.com>
6deb047 to
23e5b24
Compare
* [BUGFIX] Handle errors from disabled PSI subsystem prometheus#1983 * [BUGFIX] Sanitize strings from /sys/class/power_supply prometheus#1984 * [BUGFIX] Silence missing netclass errors prometheus#1986 Signed-off-by: Ben Kochie <superq@gmail.com>
* [BUGFIX] Handle errors from disabled PSI subsystem prometheus#1983 * [BUGFIX] Sanitize strings from /sys/class/power_supply prometheus#1984 * [BUGFIX] Silence missing netclass errors prometheus#1986 Signed-off-by: Ben Kochie <superq@gmail.com>
Avoid panic on invalid UTF-8 from /sys/class/power_supply by
sanitizing strings parsed from the kernel.
Fixes: #1979
Signed-off-by: Ben Kochie superq@gmail.com