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

Method MarshalJSON

model/value_histogram.go:142–155  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

140}
141
142func (s SampleHistogramPair) MarshalJSON() ([]byte, error) {
143 if s.Histogram == nil {
144 return nil, fmt.Errorf("histogram is nil")
145 }
146 t, err := json.Marshal(s.Timestamp)
147 if err != nil {
148 return nil, err
149 }
150 v, err := json.Marshal(s.Histogram)
151 if err != nil {
152 return nil, err
153 }
154 return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
155}
156
157func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
158 tmp := []interface{}{&s.Timestamp, &s.Histogram}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected