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

Method UnmarshalJSON

model/value_histogram.go:157–170  ·  view source on GitHub ↗
(buf []byte)

Source from the content-addressed store, hash-verified

155}
156
157func (s *SampleHistogramPair) UnmarshalJSON(buf []byte) error {
158 tmp := []interface{}{&s.Timestamp, &s.Histogram}
159 wantLen := len(tmp)
160 if err := json.Unmarshal(buf, &tmp); err != nil {
161 return err
162 }
163 if gotLen := len(tmp); gotLen != wantLen {
164 return fmt.Errorf("wrong number of fields: %d != %d", gotLen, wantLen)
165 }
166 if s.Histogram == nil {
167 return fmt.Errorf("histogram is null")
168 }
169 return nil
170}
171
172func (s SampleHistogramPair) String() string {
173 return fmt.Sprintf("%s @[%s]", s.Histogram, s.Timestamp)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected