textparse: fix NaN canonicalization check in OpenMetrics getFloatValue#18399
textparse: fix NaN canonicalization check in OpenMetrics getFloatValue#18399cuiweixie wants to merge 3 commits intoprometheus:mainfrom
Conversation
getFloatValue was testing p.exemplarVal instead of the parsed float when normalizing NaN to the canonical representation, so metric values that were NaN were not normalized correctly. Signed-off-by: Weixie Cui <[email protected]>
bboreham
left a comment
There was a problem hiding this comment.
Certainly looks plausible, but I'm intrigued: how do you get a non-canonical NaN out of strconv.ParseFloat ?
Related: could you write a test for this condition?
|
You're right that strconv.ParseFloat currently returns a canonical NaN. |
Seems like this is actually dead code, you cannot get NaN in p.exemplarVal and val cannot be abnormal NaN anyway. At least in the current implementation/architecture we're looking at. Anyway, I'm ok with the change, but I'd like to suggest making this change to the tests: I'm using summary as that's a "natural" place for NaN. |
|
If the condition cannot occur and the change is just to make the code internally consistent, this would not have a changelog entry. |
Extend TestOpenMetricsParse with nansum summary lines and cmpopts.EquateNaNs in requireEntries so NaN float values compare equal after canonicalization. Signed-off-by: Weixie Cui <[email protected]>
Document the bugfix in CHANGELOG.md (prometheus#18399). Signed-off-by: Weixie Cui <[email protected]>
ac74ccb to
940d9c7
Compare
Done |
Document the bugfix in CHANGELOG.md (prometheus#18399). Signed-off-by: Weixie Cui <[email protected]>
940d9c7 to
42d1155
Compare
getFloatValue was testing
p.exemplarValinstead of the parsed float when normalizing NaN to the canonical representation, so OpenMetrics metric sample values that were NaN were not normalized correctly.