mirror of
https://github.com/coredns/coredns.git
synced 2026-04-05 11:45:33 -04:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user