refactor(test): replace deprecated pbutil dep (#7924)

Replace github.com/matttproud/golang_protobuf_extensions/pbutil
with google.golang.org/protobuf/encoding/protodelim for reading
varint size-delimited protobuf messages in the metrics scraper.

The new protodelim package is already available via the existing
google.golang.org/protobuf dependency, so this removes pbutil as
a direct dependency entirely.

Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
Ville Vesilehto
2026-03-15 21:35:59 +02:00
committed by GitHub
parent 7ff001dca7
commit 6819d2ca6c
3 changed files with 4 additions and 7 deletions

View File

@@ -23,15 +23,16 @@
package test
import (
"bufio"
"fmt"
"io"
"mime"
"net/http"
"strconv"
"github.com/matttproud/golang_protobuf_extensions/pbutil"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"google.golang.org/protobuf/encoding/protodelim"
)
type (
@@ -235,9 +236,10 @@ func fetchMetricFamilies(url string, ch chan<- *dto.MetricFamily) {
if err == nil && mediatype == "application/vnd.google.protobuf" &&
params["encoding"] == "delimited" &&
params["proto"] == "io.prometheus.client.MetricFamily" {
reader := bufio.NewReader(resp.Body)
for {
mf := &dto.MetricFamily{}
if _, err = pbutil.ReadDelimited(resp.Body, mf); err != nil {
if err = protodelim.UnmarshalFrom(reader, mf); err != nil {
if err == io.EOF {
break
}