()
| 191 | } |
| 192 | |
| 193 | func (ss SampleStream) MarshalJSON() ([]byte, error) { |
| 194 | if len(ss.Histograms) > 0 && len(ss.Values) > 0 { |
| 195 | v := struct { |
| 196 | Metric Metric `json:"metric"` |
| 197 | Values []SamplePair `json:"values"` |
| 198 | Histograms []SampleHistogramPair `json:"histograms"` |
| 199 | }{ |
| 200 | Metric: ss.Metric, |
| 201 | Values: ss.Values, |
| 202 | Histograms: ss.Histograms, |
| 203 | } |
| 204 | return json.Marshal(&v) |
| 205 | } else if len(ss.Histograms) > 0 { |
| 206 | v := struct { |
| 207 | Metric Metric `json:"metric"` |
| 208 | Histograms []SampleHistogramPair `json:"histograms"` |
| 209 | }{ |
| 210 | Metric: ss.Metric, |
| 211 | Histograms: ss.Histograms, |
| 212 | } |
| 213 | return json.Marshal(&v) |
| 214 | } else { |
| 215 | v := struct { |
| 216 | Metric Metric `json:"metric"` |
| 217 | Values []SamplePair `json:"values"` |
| 218 | }{ |
| 219 | Metric: ss.Metric, |
| 220 | Values: ss.Values, |
| 221 | } |
| 222 | return json.Marshal(&v) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func (ss *SampleStream) UnmarshalJSON(b []byte) error { |
| 227 | v := struct { |
nothing calls this directly
no outgoing calls
no test coverage detected