MCPcopy Create free account
hub / github.com/prometheus/common / setOrCreateCurrentMF

Method setOrCreateCurrentMF

expfmt/text_parse.go:682–718  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

680}
681
682func (p *TextParser) setOrCreateCurrentMF() {
683 p.currentIsSummaryCount = false
684 p.currentIsSummarySum = false
685 p.currentIsHistogramCount = false
686 p.currentIsHistogramSum = false
687 name := p.currentToken.String()
688 if p.currentMF = p.metricFamiliesByName[name]; p.currentMF != nil {
689 return
690 }
691 // Try out if this is a _sum or _count for a summary/histogram.
692 summaryName := summaryMetricName(name)
693 if p.currentMF = p.metricFamiliesByName[summaryName]; p.currentMF != nil {
694 if p.currentMF.GetType() == dto.MetricType_SUMMARY {
695 if isCount(name) {
696 p.currentIsSummaryCount = true
697 }
698 if isSum(name) {
699 p.currentIsSummarySum = true
700 }
701 return
702 }
703 }
704 histogramName := histogramMetricName(name)
705 if p.currentMF = p.metricFamiliesByName[histogramName]; p.currentMF != nil {
706 if p.currentMF.GetType() == dto.MetricType_HISTOGRAM {
707 if isCount(name) {
708 p.currentIsHistogramCount = true
709 }
710 if isSum(name) {
711 p.currentIsHistogramSum = true
712 }
713 return
714 }
715 }
716 p.currentMF = &dto.MetricFamily{Name: proto.String(name)}
717 p.metricFamiliesByName[name] = p.currentMF
718}
719
720func isValidLabelNameStart(b byte) bool {
721 return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_'

Callers 2

startCommentMethod · 0.95
readingMetricNameMethod · 0.95

Calls 5

summaryMetricNameFunction · 0.85
isCountFunction · 0.85
isSumFunction · 0.85
histogramMetricNameFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected