()
| 191 | } |
| 192 | |
| 193 | func (ss SampleStream) MarshalJSON() ([]byte, error) { |
| 194 | switch { |
| 195 | case len(ss.Histograms) > 0 && len(ss.Values) > 0: |
| 196 | v := struct { |
| 197 | Metric Metric `json:"metric"` |
| 198 | Values []SamplePair `json:"values"` |
| 199 | Histograms []SampleHistogramPair `json:"histograms"` |
| 200 | }{ |
| 201 | Metric: ss.Metric, |
| 202 | Values: ss.Values, |
| 203 | Histograms: ss.Histograms, |
| 204 | } |
| 205 | return json.Marshal(&v) |
| 206 | case len(ss.Histograms) > 0: |
| 207 | v := struct { |
| 208 | Metric Metric `json:"metric"` |
| 209 | Histograms []SampleHistogramPair `json:"histograms"` |
| 210 | }{ |
| 211 | Metric: ss.Metric, |
| 212 | Histograms: ss.Histograms, |
| 213 | } |
| 214 | return json.Marshal(&v) |
| 215 | default: |
| 216 | v := struct { |
| 217 | Metric Metric `json:"metric"` |
| 218 | Values []SamplePair `json:"values"` |
| 219 | }{ |
| 220 | Metric: ss.Metric, |
| 221 | Values: ss.Values, |
| 222 | } |
| 223 | return json.Marshal(&v) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Scalar is a scalar value evaluated at the set timestamp. |
| 228 | type Scalar struct { |
nothing calls this directly
no outgoing calls
no test coverage detected