Skip to content

Commit

Permalink
Cleanup proto use in tests
Browse files Browse the repository at this point in the history
Switch tests over to new proto libary, eliminating the direct dependency
on the old proto library. Note the indirect requirement is still needed
due to upstream use by the client_model package.

Related: #1175

Signed-off-by: SuperQ <superq@gmail.com>
  • Loading branch information
SuperQ committed May 1, 2023
1 parent 671a2f0 commit 71a1761
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/beorn7/perks v1.0.1
github.com/cespare/xxhash/v2 v2.2.0
github.com/davecgh/go-spew v1.1.1
github.com/golang/protobuf v1.5.3
github.com/json-iterator/go v1.1.12
github.com/prometheus/client_model v0.3.0
github.com/prometheus/common v0.42.0
Expand All @@ -16,6 +15,7 @@ require (
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand Down
5 changes: 2 additions & 3 deletions prometheus/example_metricvec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ package prometheus_test
import (
"fmt"

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

dto "github.com/prometheus/client_model/go"

Expand Down Expand Up @@ -127,7 +126,7 @@ func ExampleMetricVec() {
if err != nil || len(metricFamilies) != 1 {
panic("unexpected behavior of custom test registry")
}
fmt.Println(proto.MarshalTextString(metricFamilies[0]))
fmt.Println(metricFamilies[0].String())

// Output:
// name: "library_version_info"
Expand Down
16 changes: 7 additions & 9 deletions prometheus/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"strings"
"time"

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

Expand Down Expand Up @@ -321,7 +319,7 @@ func ExampleSummary() {
// internally).
metric := &dto.Metric{}
temps.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// summary: <
Expand Down Expand Up @@ -371,7 +369,7 @@ func ExampleSummaryVec() {
if err != nil || len(metricFamilies) != 1 {
panic("unexpected behavior of custom test registry")
}
fmt.Println(proto.MarshalTextString(metricFamilies[0]))
fmt.Println(metricFamilies[0].String())

// Output:
// name: "pond_temperature_celsius"
Expand Down Expand Up @@ -466,7 +464,7 @@ func ExampleNewConstSummary() {
// internally).
metric := &dto.Metric{}
s.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// label: <
Expand Down Expand Up @@ -512,7 +510,7 @@ func ExampleHistogram() {
// internally).
metric := &dto.Metric{}
temps.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// histogram: <
Expand Down Expand Up @@ -562,7 +560,7 @@ func ExampleNewConstHistogram() {
// internally).
metric := &dto.Metric{}
h.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// label: <
Expand Down Expand Up @@ -631,7 +629,7 @@ func ExampleNewConstHistogram_WithExemplar() {
// internally).
metric := &dto.Metric{}
h.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// label: <
Expand Down Expand Up @@ -858,7 +856,7 @@ func ExampleNewMetricWithTimestamp() {
// internally).
metric := &dto.Metric{}
s.Write(metric)
fmt.Println(proto.MarshalTextString(metric))
fmt.Println(metric.String())

// Output:
// gauge: <
Expand Down

0 comments on commit 71a1761

Please sign in to comment.