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

Function ExtractSamples

expfmt/decode.go:172–186  ·  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

170// extract from the remaining metric families. The returned error is the last
171// error that has occurred.
172func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) (model.Vector, error) {
173 var (
174 all model.Vector
175 lastErr error
176 )
177 for _, f := range fams {
178 some, err := extractSamples(f, o)
179 if err != nil {
180 lastErr = err
181 continue
182 }
183 all = append(all, some...)
184 }
185 return all, lastErr
186}
187
188func extractSamples(f *dto.MetricFamily, o *DecodeOptions) (model.Vector, error) {
189 switch f.GetType() {

Callers 1

TestExtractSamplesFunction · 0.85

Calls 1

extractSamplesFunction · 0.85

Tested by 1

TestExtractSamplesFunction · 0.68