Skip to content

Commit

Permalink
use expfmt.NewFormat instead of now-private formats directly
Browse files Browse the repository at this point in the history
These were removed upstream in prometheus/common#576
  • Loading branch information
roobre committed Mar 5, 2024
1 parent 2c7e183 commit 359e503
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/k6runner/k6runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (rc *checkResultCollector) process(mf *dto.MetricFamily, sample *model.Samp
}

func extractMetricSamples(metrics []byte, logger zerolog.Logger, processors ...sampleProcessorFunc) error {
promDecoder := expfmt.NewDecoder(bytes.NewBuffer(metrics), expfmt.FmtText)
promDecoder := expfmt.NewDecoder(bytes.NewBuffer(metrics), expfmt.NewFormat(expfmt.TypeTextPlain))
decoderOpts := expfmt.DecodeOptions{Timestamp: model.Now()}
for {
var mf dto.MetricFamily
Expand Down
5 changes: 2 additions & 3 deletions internal/k6runner/k6runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func TestTextToRegistry(t *testing.T) {

expectedMetrics := map[string]struct{}{}

promDecoder := expfmt.NewDecoder(bytes.NewBuffer(data), expfmt.FmtText)
promDecoder := expfmt.NewDecoder(bytes.NewBuffer(data), expfmt.NewFormat(expfmt.TypeTextPlain))
DEC_LOOP:
for {
var mf dto.MetricFamily
Expand Down Expand Up @@ -262,8 +262,7 @@ func TestK6LogsToLogger(t *testing.T) {
require.NoError(t, err)
}

type testLogger struct {
}
type testLogger struct{}

var _ logger.Logger = &testLogger{}

Expand Down
4 changes: 2 additions & 2 deletions internal/scraper/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func verifyProberMetrics(
if *updateGolden {
var buf bytes.Buffer

enc := expfmt.NewEncoder(&buf, expfmt.FmtText)
enc := expfmt.NewEncoder(&buf, expfmt.NewFormat(expfmt.TypeTextPlain))

for _, m := range mfs {
if err := enc.Encode(m); err != nil {
Expand Down Expand Up @@ -515,7 +515,7 @@ func readGoldenFile(fn string) (map[string]struct{}, error) {
}
defer fh.Close()

dec := expfmt.NewDecoder(fh, expfmt.FmtText)
dec := expfmt.NewDecoder(fh, expfmt.NewFormat(expfmt.TypeTextPlain))

metrics := map[string]struct{}{}

Expand Down

0 comments on commit 359e503

Please sign in to comment.