MCPcopy Index your code
hub / github.com/prometheus/prometheus / getMagicLabel

Method getMagicLabel

model/textparse/protobufparse.go:675–701  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

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.
675func (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

Callers 1

Calls 7

FormatOpenMetricsFloatFunction · 0.92
GetSummaryMethod · 0.80
GetBucketMethod · 0.80
GetHistogramMethod · 0.80
GetUpperBoundMethod · 0.80
GetTypeMethod · 0.45
GetQuantileMethod · 0.45

Tested by

no test coverage detected