MCPcopy Create free account
hub / github.com/prometheus/common / MarshalJSON

Method MarshalJSON

model/value.go:193–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191}
192
193func (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
226func (ss *SampleStream) UnmarshalJSON(b []byte) error {
227 v := struct {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected