Skip to content

Commit

Permalink
Replace deprecated github.com/golang/protobuf package
Browse files Browse the repository at this point in the history
This replaces usage of proto.{Float64,Int32,Int64,String,Uint32,Uint64},
which doesn't break the interface.

And replaces ptypes.TimestampProto by google.golang.org/protobuf/types/known/timestamppb.
This works since github.com/golang/protobuf has been bumped to v1.5.2,
which makes ptypes.TimestampProto an alias to timestamppb.Timestamp.
This is only used test (openmetrics_create_test.go), which won't break
interfaces.

Updates: prometheus#317

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
  • Loading branch information
zhsj committed Mar 1, 2023
1 parent ab87968 commit 9511718
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 209 deletions.
17 changes: 8 additions & 9 deletions expfmt/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"strings"
"testing"

"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
dto "github.com/prometheus/client_model/go"

"github.com/prometheus/common/model"

dto "github.com/prometheus/client_model/go"
"google.golang.org/protobuf/proto"
)

func TestTextDecoder(t *testing.T) {
Expand Down Expand Up @@ -100,8 +100,7 @@ mf2 4
}

func TestProtoDecoder(t *testing.T) {

var testTime = model.Now()
testTime := model.Now()

scenarios := []struct {
in string
Expand Down Expand Up @@ -369,7 +368,7 @@ func TestProtoDecoder(t *testing.T) {
}

func testDiscriminatorHTTPHeader(t testing.TB) {
var scenarios = []struct {
scenarios := []struct {
input map[string]string
output Format
}{
Expand Down Expand Up @@ -435,7 +434,7 @@ func TestExtractSamples(t *testing.T) {
Help: proto.String("Help for foo."),
Type: dto.MetricType_COUNTER.Enum(),
Metric: []*dto.Metric{
&dto.Metric{
{
Counter: &dto.Counter{
Value: proto.Float64(4711),
},
Expand All @@ -447,7 +446,7 @@ func TestExtractSamples(t *testing.T) {
Help: proto.String("Help for bar."),
Type: dto.MetricType_GAUGE.Enum(),
Metric: []*dto.Metric{
&dto.Metric{
{
Gauge: &dto.Gauge{
Value: proto.Float64(3.14),
},
Expand All @@ -459,7 +458,7 @@ func TestExtractSamples(t *testing.T) {
Help: proto.String("Help for bad."),
Type: dto.MetricType(42).Enum(),
Metric: []*dto.Metric{
&dto.Metric{
{
Gauge: &dto.Gauge{
Value: proto.Float64(2.7),
},
Expand Down
2 changes: 1 addition & 1 deletion expfmt/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"net/http"
"testing"

"github.com/golang/protobuf/proto" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
dto "github.com/prometheus/client_model/go"
"google.golang.org/protobuf/proto"
)

func TestNegotiate(t *testing.T) {
Expand Down
Loading

0 comments on commit 9511718

Please sign in to comment.