File tree Expand file tree Collapse file tree 1 file changed +4
-22
lines changed Expand file tree Collapse file tree 1 file changed +4
-22
lines changed Original file line number Diff line number Diff line change @@ -100,37 +100,19 @@ func (s Sample) MarshalJSON() ([]byte, error) {
100
100
return json .Marshal (& v )
101
101
}
102
102
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
-
120
103
// UnmarshalJSON implements json.Unmarshaler.
121
- // TODO: simplify and remove the need for both sampleHistogramPairPtr and SampleHistogramPair
122
104
func (s * Sample ) UnmarshalJSON (b []byte ) error {
123
105
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"`
127
109
}{
128
110
Metric : s .Metric ,
129
111
Value : SamplePair {
130
112
Timestamp : s .Timestamp ,
131
113
Value : s .Value ,
132
114
},
133
- Histogram : sampleHistogramPairPtr {
115
+ Histogram : SampleHistogramPair {
134
116
Timestamp : s .Timestamp ,
135
117
Histogram : s .Histogram ,
136
118
},
You can’t perform that action at this time.
0 commit comments