diff --git a/model/textparse/openmetricsparse.go b/model/textparse/openmetricsparse.go index 800e9467d..c32424284 100644 --- a/model/textparse/openmetricsparse.go +++ b/model/textparse/openmetricsparse.go @@ -486,7 +486,7 @@ func (p *OpenMetricsParser) parseMetricSuffix(t token) (Entry, error) { var ts float64 // A float is enough to hold what we need for millisecond resolution. if ts, err = parseFloat(yoloString(p.l.buf()[1:])); err != nil { - return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) + return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i]) } if math.IsNaN(ts) || math.IsInf(ts, 0) { return EntryInvalid, fmt.Errorf("invalid timestamp %f", ts) diff --git a/model/textparse/openmetricsparse_test.go b/model/textparse/openmetricsparse_test.go index 63a1583b1..2ad26a616 100644 --- a/model/textparse/openmetricsparse_test.go +++ b/model/textparse/openmetricsparse_test.go @@ -302,7 +302,7 @@ foo_total 17.0 1520879607.789 # {id="counter-test"} 5` func TestUTF8OpenMetricsParse(t *testing.T) { model.NameValidationScheme = model.UTF8Validation - defer func(){ + defer func() { model.NameValidationScheme = model.LegacyValidation }() diff --git a/model/textparse/promparse.go b/model/textparse/promparse.go index 350d52166..58129720f 100644 --- a/model/textparse/promparse.go +++ b/model/textparse/promparse.go @@ -462,7 +462,7 @@ func (p *PromParser) parseMetricSuffix(t token) (Entry, error) { } var err error if p.val, err = parseFloat(yoloString(p.l.buf())); err != nil { - return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) + return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i]) } // Ensure canonical NaN value. if math.IsNaN(p.val) { @@ -475,7 +475,7 @@ func (p *PromParser) parseMetricSuffix(t token) (Entry, error) { case tTimestamp: p.hasTS = true if p.ts, err = strconv.ParseInt(yoloString(p.l.buf()), 10, 64); err != nil { - return EntryInvalid, fmt.Errorf("%v while parsing: %q", err, p.l.b[p.start:p.l.i]) + return EntryInvalid, fmt.Errorf("%w while parsing: %q", err, p.l.b[p.start:p.l.i]) } if t2 := p.nextToken(); t2 != tLinebreak { return EntryInvalid, p.parseError("expected next entry after timestamp", t2)