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

Function ExtractSamples

expfmt/decode.go:276–290  ·  view source on GitHub ↗

ExtractSamples builds a slice of samples from the provided metric families. If an error occurs during sample extraction, it continues to extract from the remaining metric families. The returned error is the last error that has occurred.

(o *DecodeOptions, fams ...*dto.MetricFamily)

Source from the content-addressed store, hash-verified

274// extract from the remaining metric families. The returned error is the last
275// error that has occurred.
276func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) (model.Vector, error) {
277 var (
278 all model.Vector
279 lastErr error
280 )
281 for _, f := range fams {
282 some, err := extractSamples(f, o)
283 if err != nil {
284 lastErr = err
285 continue
286 }
287 all = append(all, some...)
288 }
289 return all, lastErr
290}
291
292func extractSamples(f *dto.MetricFamily, o *DecodeOptions) (model.Vector, error) {
293 switch f.GetType() {

Callers 1

TestExtractSamplesFunction · 0.85

Calls 1

extractSamplesFunction · 0.85

Tested by 1

TestExtractSamplesFunction · 0.68