getMagicLabel returns if a magic label ("quantile" or "le") is needed and, if so, its name and value. It also sets p.fieldsDone if applicable.
()
| 673 | // getMagicLabel returns if a magic label ("quantile" or "le") is needed and, if |
| 674 | // so, its name and value. It also sets p.fieldsDone if applicable. |
| 675 | func (p *ProtobufParser) getMagicLabel() (bool, string, string) { |
| 676 | // Native histogram or _count and _sum series. |
| 677 | if p.state == EntryHistogram || p.fieldPos < 0 { |
| 678 | return false, "", "" |
| 679 | } |
| 680 | switch p.dec.GetType() { |
| 681 | case dto.MetricType_SUMMARY: |
| 682 | qq := p.dec.GetSummary().GetQuantile() |
| 683 | if p.fieldPos >= len(qq) { |
| 684 | p.fieldsDone = true |
| 685 | return false, "", "" |
| 686 | } |
| 687 | q := qq[p.fieldPos] |
| 688 | p.fieldsDone = p.fieldPos == len(qq)-1 |
| 689 | return true, model.QuantileLabel, labels.FormatOpenMetricsFloat(q.GetQuantile()) |
| 690 | case dto.MetricType_HISTOGRAM, dto.MetricType_GAUGE_HISTOGRAM: |
| 691 | bb := p.dec.GetHistogram().GetBucket() |
| 692 | if p.fieldPos >= len(bb) { |
| 693 | p.fieldsDone = true |
| 694 | return true, model.BucketLabel, "+Inf" |
| 695 | } |
| 696 | b := bb[p.fieldPos] |
| 697 | p.fieldsDone = math.IsInf(b.GetUpperBound(), +1) |
| 698 | return true, model.BucketLabel, labels.FormatOpenMetricsFloat(b.GetUpperBound()) |
| 699 | } |
| 700 | return false, "", "" |
| 701 | } |
| 702 | |
| 703 | // isNativeHistogram returns false iff the provided histograms has no spans at |
| 704 | // all (neither positive nor negative) and a zero threshold of 0 and a zero |
no test coverage detected