textparse: fix NaN canonicalization check in OpenMetrics getFloatValue

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 <cuiweixie@gmail.com>
This commit is contained in:
Weixie Cui 2026-03-30 17:41:32 +08:00
parent d6c18a4d62
commit e28ae3eb6c

View file

@ -763,7 +763,7 @@ func (p *OpenMetricsParser) getFloatValue(t token, after string) (float64, error
return 0, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i])
}
// Ensure canonical NaN value.
if math.IsNaN(p.exemplarVal) {
if math.IsNaN(val) {
val = math.Float64frombits(value.NormalNaN)
}
return val, nil