Skip to content

Commit c075304

Browse files
committed
Update usage of expfmt.TextParser to avoid panic
This adjusts to the prometheus/common behavior introduced in v0.66. Signed-off-by: beorn7 <beorn@grafana.com>
1 parent 1d7b8c0 commit c075304

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

prom2json.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/matttproud/golang_protobuf_extensions/pbutil"
2323
"github.com/prometheus/common/expfmt"
24+
"github.com/prometheus/common/model"
2425

2526
dto "github.com/prometheus/client_model/go"
2627
"github.com/prometheus/prom2json/histogram"
@@ -231,7 +232,7 @@ func ParseReader(in io.Reader, ch chan<- *dto.MetricFamily) error {
231232
// We could do further content-type checks here, but the
232233
// fallback for now will anyway be the text format
233234
// version 0.0.4, so just go for it and see if it works.
234-
var parser expfmt.TextParser
235+
parser := expfmt.NewTextParser(model.UTF8Validation)
235236
metricFamilies, err := parser.TextToMetricFamilies(in)
236237
if err != nil {
237238
return fmt.Errorf("reading text format failed: %v", err)

0 commit comments

Comments
 (0)