Skip to content

Commit

Permalink
Add generic interface for float/histogram sample pair (bumping go ver…
Browse files Browse the repository at this point in the history
…sion - experimental)

Signed-off-by: Jeanette Tan <[email protected]>
  • Loading branch information
zenador committed Dec 23, 2022
1 parent 792823a commit 14ed1f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/prometheus/common

go 1.17
go 1.18

require (
github.com/go-kit/log v0.2.1
Expand Down
5 changes: 5 additions & 0 deletions model/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,8 @@ func (mat Matrix) String() string {

return strings.Join(strs, "\n")
}

type GenericSamplePair interface {
SamplePair | SampleHistogramPair
GetTimestamp() Time
}
4 changes: 4 additions & 0 deletions model/value_float.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ func (s *SamplePair) Equal(o *SamplePair) bool {
func (s SamplePair) String() string {
return fmt.Sprintf("%s @[%s]", s.Value, s.Timestamp)
}

func (s SamplePair) GetTimestamp() Time {
return s.Timestamp
}
4 changes: 4 additions & 0 deletions model/value_histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ func (s SampleHistogramPair) String() string {
func (s *SampleHistogramPair) Equal(o *SampleHistogramPair) bool {
return s == o || (s.Histogram.Equal(&o.Histogram) && s.Timestamp.Equal(o.Timestamp))
}

func (s SampleHistogramPair) GetTimestamp() Time {
return s.Timestamp
}

0 comments on commit 14ed1f8

Please sign in to comment.