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)
| 202 | // extract from the remaining metric families. The returned error is the last |
| 203 | // error that has occurred. |
| 204 | func ExtractSamples(o *DecodeOptions, fams ...*dto.MetricFamily) (model.Vector, error) { |
| 205 | var ( |
| 206 | all model.Vector |
| 207 | lastErr error |
| 208 | ) |
| 209 | for _, f := range fams { |
| 210 | some, err := extractSamples(f, o) |
| 211 | if err != nil { |
| 212 | lastErr = err |
| 213 | continue |
| 214 | } |
| 215 | all = append(all, some...) |
| 216 | } |
| 217 | return all, lastErr |
| 218 | } |
| 219 | |
| 220 | func extractSamples(f *dto.MetricFamily, o *DecodeOptions) (model.Vector, error) { |
| 221 | switch f.GetType() { |