(o *DecodeOptions, f *dto.MetricFamily)
| 377 | } |
| 378 | |
| 379 | func extractHistogram(o *DecodeOptions, f *dto.MetricFamily) model.Vector { |
| 380 | samples := make(model.Vector, 0, len(f.Metric)) |
| 381 | |
| 382 | for _, m := range f.Metric { |
| 383 | if m.Histogram == nil { |
| 384 | continue |
| 385 | } |
| 386 | |
| 387 | timestamp := o.Timestamp |
| 388 | if m.TimestampMs != nil { |
| 389 | timestamp = model.TimeFromUnixNano(*m.TimestampMs * 1000000) |
| 390 | } |
| 391 | |
| 392 | infSeen := false |
| 393 | |
| 394 | for _, q := range m.Histogram.Bucket { |
| 395 | lset := make(model.LabelSet, len(m.Label)+2) |
| 396 | for _, p := range m.Label { |
| 397 | lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue()) |
| 398 | } |
| 399 | lset[model.LabelName(model.BucketLabel)] = model.LabelValue(fmt.Sprint(q.GetUpperBound())) |
| 400 | lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_bucket") |
| 401 | |
| 402 | if math.IsInf(q.GetUpperBound(), +1) { |
| 403 | infSeen = true |
| 404 | } |
| 405 | |
| 406 | v := q.GetCumulativeCountFloat() |
| 407 | if v <= 0 { |
| 408 | v = float64(q.GetCumulativeCount()) |
| 409 | } |
| 410 | samples = append(samples, &model.Sample{ |
| 411 | Metric: model.Metric(lset), |
| 412 | Value: model.SampleValue(v), |
| 413 | Timestamp: timestamp, |
| 414 | }) |
| 415 | } |
| 416 | |
| 417 | lset := make(model.LabelSet, len(m.Label)+1) |
| 418 | for _, p := range m.Label { |
| 419 | lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue()) |
| 420 | } |
| 421 | lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_sum") |
| 422 | |
| 423 | samples = append(samples, &model.Sample{ |
| 424 | Metric: model.Metric(lset), |
| 425 | Value: model.SampleValue(m.Histogram.GetSampleSum()), |
| 426 | Timestamp: timestamp, |
| 427 | }) |
| 428 | |
| 429 | lset = make(model.LabelSet, len(m.Label)+1) |
| 430 | for _, p := range m.Label { |
| 431 | lset[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue()) |
| 432 | } |
| 433 | lset[model.MetricNameLabel] = model.LabelValue(f.GetName() + "_count") |
| 434 | |
| 435 | v := m.Histogram.GetSampleCountFloat() |
| 436 | if v <= 0 { |
no test coverage detected
searching dependent graphs…