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

Method MarshalJSON

model/value_histogram.go:143–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected