(o *DecodeOptions, f *dto.MetricFamily)
| 202 | } |
| 203 | |
| 204 | func extractCounter(o *DecodeOptions, f *dto.MetricFamily) model.Vector { |
| 205 | samples := make(model.Vector, 0, len(f.Metric)) |
| 206 | |
| 207 | for _, m := range f.Metric { |
| 208 | if m.Counter == nil { |
| 209 | continue |
| 210 | } |
| 211 | |
| 212 | lset := make(model.LabelSet, len(m.Label)+1) |
| 213 | for _, p := range m.Label { |
| 214 | lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue()) |
| 215 | } |
| 216 | lset[model.MetricNameLabel] = model.LabelValue(f.GetName()) |
| 217 | |
| 218 | smpl := &model.Sample{ |
| 219 | Metric: model.Metric(lset), |
| 220 | Value: model.SampleValue(m.Counter.GetValue()), |
| 221 | } |
| 222 | |
| 223 | if m.TimestampMs != nil { |
| 224 | smpl.Timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000) |
| 225 | } else { |
| 226 | smpl.Timestamp = o.Timestamp |
| 227 | } |
| 228 | |
| 229 | samples = append(samples, smpl) |
| 230 | } |
| 231 | |
| 232 | return samples |
| 233 | } |
| 234 | |
| 235 | func extractGauge(o *DecodeOptions, f *dto.MetricFamily) model.Vector { |
| 236 | samples := make(model.Vector, 0, len(f.Metric)) |
no test coverage detected