1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
Description: Support building against golang-goprotobuf-dev < v1.4.0
Starting with version 1.4.0 of github.com/golang/protobuf, timestamp.Timestamp
is a type alias of timestamppb.Timestamp from google.golang.org/protobuf
(packaged in Debian as golang-google-protobuf-dev). This patch applies the
necessary workarounds to build against golang-github-golang-protobuf-1-3-dev.
Despite golang-github-golang-protobuf-1-5-dev also now existing in sid, it
mutually conflicts with golang-github-golang-protobuf-1-3-dev, and since
golang-github-prometheus-client-golang and golang-github-prometheus-common
cyclically depend on each other, this currently creates a stalemate situation.
Author: Daniel Swarbrick <dswarbrick@debian.org>
Forwarded: not-needed
Last-Update: 2022-09-16
--- a/prometheus/value.go
+++ b/prometheus/value.go
@@ -21,6 +21,7 @@ import (
//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/prometheus/client_golang/prometheus/internal"
@@ -212,7 +213,7 @@ func newExemplar(value float64, ts time.
if err := tsProto.CheckValid(); err != nil {
return nil, err
}
- e.Timestamp = tsProto
+ e.Timestamp = ×tamp.Timestamp{Seconds: tsProto.GetSeconds(), Nanos: tsProto.GetNanos()}
labelPairs := make([]*dto.LabelPair, 0, len(l))
var runes int
for name, value := range l {
--- a/prometheus/counter_test.go
+++ b/prometheus/counter_test.go
@@ -22,6 +22,7 @@ import (
//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
dto "github.com/prometheus/client_model/go"
@@ -235,7 +236,7 @@ func TestCounterExemplar(t *testing.T) {
{Name: proto.String("foo"), Value: proto.String("bar")},
},
Value: proto.Float64(42),
- Timestamp: ts,
+ Timestamp: ×tamp.Timestamp{Seconds: ts.GetSeconds(), Nanos: ts.GetNanos()},
}
counter.AddWithExemplar(42, Labels{"foo": "bar"})
--- a/prometheus/histogram_test.go
+++ b/prometheus/histogram_test.go
@@ -27,6 +27,7 @@ import (
//nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility.
"github.com/golang/protobuf/proto"
+ "github.com/golang/protobuf/ptypes/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/prometheus/client_golang/prometheus/internal"
@@ -432,7 +433,7 @@ func TestHistogramExemplar(t *testing.T)
{Name: proto.String("id"), Value: proto.String("2")},
},
Value: proto.Float64(1.6),
- Timestamp: ts,
+ Timestamp: ×tamp.Timestamp{Seconds: ts.GetSeconds(), Nanos: ts.GetNanos()},
},
nil,
{
@@ -440,14 +441,14 @@ func TestHistogramExemplar(t *testing.T)
{Name: proto.String("id"), Value: proto.String("3")},
},
Value: proto.Float64(4),
- Timestamp: ts,
+ Timestamp: ×tamp.Timestamp{Seconds: ts.GetSeconds(), Nanos: ts.GetNanos()},
},
{
Label: []*dto.LabelPair{
{Name: proto.String("id"), Value: proto.String("4")},
},
Value: proto.Float64(4.5),
- Timestamp: ts,
+ Timestamp: ×tamp.Timestamp{Seconds: ts.GetSeconds(), Nanos: ts.GetNanos()},
},
}
|