Skip to content

Commit 14a8016

Browse files
committed
Remove sampleHistogramPairPtr
Signed-off-by: Jeanette Tan <[email protected]>
1 parent 0e0dee6 commit 14a8016

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

model/value.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -100,37 +100,19 @@ func (s Sample) MarshalJSON() ([]byte, error) {
100100
return json.Marshal(&v)
101101
}
102102

103-
type sampleHistogramPairPtr struct {
104-
Timestamp Time
105-
Histogram *SampleHistogram
106-
}
107-
108-
func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error {
109-
tmp := []interface{}{&s.Timestamp, &s.Histogram}
110-
wantLen := len(tmp)
111-
if err := json.Unmarshal(buf, &tmp); err != nil {
112-
return err
113-
}
114-
if gotLen := len(tmp); gotLen != wantLen {
115-
return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
116-
}
117-
return nil
118-
}
119-
120103
// UnmarshalJSON implements json.Unmarshaler.
121-
// TODO: simplify and remove the need for both sampleHistogramPairPtr and SampleHistogramPair
122104
func (s *Sample) UnmarshalJSON(b []byte) error {
123105
v := struct {
124-
Metric Metric `json:"metric"`
125-
Value SamplePair `json:"value"`
126-
Histogram sampleHistogramPairPtr `json:"histogram"`
106+
Metric Metric `json:"metric"`
107+
Value SamplePair `json:"value"`
108+
Histogram SampleHistogramPair `json:"histogram"`
127109
}{
128110
Metric: s.Metric,
129111
Value: SamplePair{
130112
Timestamp: s.Timestamp,
131113
Value: s.Value,
132114
},
133-
Histogram: sampleHistogramPairPtr{
115+
Histogram: SampleHistogramPair{
134116
Timestamp: s.Timestamp,
135117
Histogram: s.Histogram,
136118
},

0 commit comments

Comments
 (0)