Skip to content

Commit 41cdb02

Browse files
committed
Remove sampleHistogramPairPtr
1 parent b316e2e commit 41cdb02

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

model/value.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ func (s Sample) MarshalJSON() ([]byte, error) {
9898
return json.Marshal(&v)
9999
}
100100

101-
type sampleHistogramPairPtr struct {
102-
Timestamp Time
103-
Histogram *SampleHistogram
104-
}
105-
106101
func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error {
107102
tmp := []interface{}{&s.Timestamp, &s.Histogram}
108103
wantLen := len(tmp)
@@ -118,18 +113,18 @@ func (s *sampleHistogramPairPtr) UnmarshalJSON(buf []byte) error {
118113
// UnmarshalJSON implements json.Unmarshaler.
119114
func (s *Sample) UnmarshalJSON(b []byte) error {
120115
v := struct {
121-
Metric Metric `json:"metric"`
122-
Value SamplePair `json:"value"`
123-
Histogram sampleHistogramPairPtr `json:"histogram"`
116+
Metric Metric `json:"metric"`
117+
Value SamplePair `json:"value"`
118+
Histogram *SampleHistogramPair `json:"histogram"`
124119
}{
125120
Metric: s.Metric,
126121
Value: SamplePair{
127122
Timestamp: s.Timestamp,
128123
Value: s.Value,
129124
},
130-
Histogram: sampleHistogramPairPtr{
125+
Histogram: &SampleHistogramPair{
131126
Timestamp: s.Timestamp,
132-
Histogram: s.Histogram,
127+
Histogram: *s.Histogram,
133128
},
134129
}
135130

@@ -138,9 +133,9 @@ func (s *Sample) UnmarshalJSON(b []byte) error {
138133
}
139134

140135
s.Metric = v.Metric
141-
if v.Histogram.Histogram != nil {
136+
if v.Histogram != nil {
142137
s.Timestamp = v.Histogram.Timestamp
143-
s.Histogram = v.Histogram.Histogram
138+
s.Histogram = &v.Histogram.Histogram
144139
} else {
145140
s.Timestamp = v.Value.Timestamp
146141
s.Value = v.Value.Value

0 commit comments

Comments
 (0)