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

Method UnmarshalJSON

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected