Skip to content

Commit 2c72cbc

Browse files
committed
Properly create TextParser object
Signed-off-by: Owen Williams <[email protected]>
1 parent 5a992e9 commit 2c72cbc

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

internal/e2e/metric_stability_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"time"
1717

1818
"github.com/prometheus/common/expfmt"
19+
"github.com/prometheus/common/model"
1920
"github.com/stretchr/testify/assert"
2021
"github.com/stretchr/testify/require"
2122

@@ -51,7 +52,7 @@ func assertMetrics(t *testing.T, metricsAddr string, expectedMetrics map[string]
5152
defer resp.Body.Close()
5253

5354
reader := bufio.NewReader(resp.Body)
54-
var parser expfmt.TextParser
55+
parser := expfmt.NewTextParser(model.UTF8Validation)
5556
parsed, err := parser.TextToMetricFamilies(reader)
5657
if err != nil {
5758
return false

service/service_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"time"
1717

1818
"github.com/prometheus/common/expfmt"
19+
"github.com/prometheus/common/model"
1920
"github.com/stretchr/testify/assert"
2021
"github.com/stretchr/testify/require"
2122
config "go.opentelemetry.io/contrib/otelconf/v0.3.0"
@@ -699,7 +700,7 @@ func assertMetrics(t *testing.T, metricsAddr string, expectedLabels map[string]l
699700
})
700701
reader := bufio.NewReader(resp.Body)
701702

702-
var parser expfmt.TextParser
703+
parser := expfmt.NewTextParser(model.UTF8Validation)
703704
parsed, err := parser.TextToMetricFamilies(reader)
704705
require.NoError(t, err)
705706

service/telemetry/otelconftelemetry/metrics_test.go

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

1313
io_prometheus_client "github.com/prometheus/client_model/go"
1414
"github.com/prometheus/common/expfmt"
15+
"github.com/prometheus/common/model"
1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/require"
1718
config "go.opentelemetry.io/contrib/otelconf/v0.3.0"
@@ -183,7 +184,7 @@ func getMetricsFromPrometheus(t *testing.T, endpoint string) map[string]*io_prom
183184
require.Equal(t, http.StatusOK, rr.StatusCode, "unexpected status code after %d attempts", maxRetries)
184185
defer rr.Body.Close()
185186

186-
var parser expfmt.TextParser
187+
parser := expfmt.NewTextParser(model.UTF8Validation)
187188
parsed, err := parser.TextToMetricFamilies(rr.Body)
188189
require.NoError(t, err)
189190

0 commit comments

Comments
 (0)