Skip to content

Commit c7d608b

Browse files
committed
fix hubble_test
1 parent fb3f6c5 commit c7d608b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/integration/prometheus/prometheus.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
io_prometheus_client "github.com/prometheus/client_model/go"
1111
"github.com/prometheus/common/expfmt"
12+
"github.com/prometheus/common/model"
1213
)
1314

1415
var (
@@ -43,15 +44,16 @@ func ParseReaderMetrics(input io.Reader) (map[string]*io_prometheus_client.Metri
4344
}
4445

4546
func ParseStringMetrics(input string) (map[string]*io_prometheus_client.MetricFamily, error) {
46-
var parser expfmt.TextParser
47+
// use NewTextParser with explicit validation scheme
48+
parser := expfmt.NewTextParser(model.UTF8Validation)
4749
reader := strings.NewReader(input)
4850
return parser.TextToMetricFamilies(reader) //nolint
4951
}
5052

5153
// SelectMetric retrieves a particular metric from a map of MetricFamily based on the name (key) and
52-
// the provided label kv pairs. Every label kv pair on the metric must match for it to be returned
54+
// the provided label kv pairs. Every label kv pair on the metric must match for it to be returned.
5355
// For example, to match the following metric: my_metric{a="1",b="udp"} 7
54-
// name must be "my_metric", and the map of matchLabels must be exactly {"a": "1", "b": "udp"}
56+
// name must be "my_metric", and the map of matchLabels must be exactly {"a": "1", "b": "udp"}.
5557
func SelectMetric(metrics map[string]*io_prometheus_client.MetricFamily, name string, matchLabels map[string]string) (*io_prometheus_client.Metric, error) {
5658
metricFamily := metrics[name]
5759
if metricFamily == nil {

0 commit comments

Comments
 (0)