(o *DecodeOptions, f *dto.MetricFamily)
| 227 | } |
| 228 | |
| 229 | func extractCounter(o *DecodeOptions, f *dto.MetricFamily) model.Vector { |
| 230 | samples := make(model.Vector, 0, len(f.Metric)) |
| 231 | |
| 232 | for _, m := range f.Metric { |
| 233 | if m.Counter == nil { |
| 234 | continue |
| 235 | } |
| 236 | |
| 237 | lset := make(model.LabelSet, len(m.Label)+1) |
| 238 | for _, p := range m.Label { |
| 239 | lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue()) |
| 240 | } |
| 241 | lset[model.MetricNameLabel] = model.LabelValue(f.GetName()) |
| 242 | |
| 243 | smpl := &model.Sample{ |
| 244 | Metric: model.Metric(lset), |
| 245 | Value: model.SampleValue(m.Counter.GetValue()), |
| 246 | } |
| 247 | |
| 248 | if m.TimestampMs != nil { |
| 249 | smpl.Timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000) |
| 250 | } else { |
| 251 | smpl.Timestamp = o.Timestamp |
| 252 | } |
| 253 | |
| 254 | samples = append(samples, smpl) |
| 255 | } |
| 256 | |
| 257 | return samples |
| 258 | } |
| 259 | |
| 260 | func extractGauge(o *DecodeOptions, f *dto.MetricFamily) model.Vector { |
| 261 | samples := make(model.Vector, 0, len(f.Metric)) |
no test coverage detected
searching dependent graphs…