()
| 901 | } |
| 902 | |
| 903 | func (p *TextParser) setOrCreateCurrentMF() { |
| 904 | p.currentIsSummaryCount = false |
| 905 | p.currentIsSummarySum = false |
| 906 | p.currentIsHistogramCount = false |
| 907 | p.currentIsHistogramSum = false |
| 908 | name := p.currentToken.String() |
| 909 | if !p.scheme.IsValidMetricName(name) { |
| 910 | p.parseError(fmt.Sprintf("invalid metric name %q", name)) |
| 911 | return |
| 912 | } |
| 913 | if p.currentMF = p.metricFamiliesByName[name]; p.currentMF != nil { |
| 914 | return |
| 915 | } |
| 916 | // Try out if this is a _sum or _count for a summary/histogram. |
| 917 | summaryName := summaryMetricName(name) |
| 918 | if p.currentMF = p.metricFamiliesByName[summaryName]; p.currentMF != nil { |
| 919 | if p.currentMF.GetType() == dto.MetricType_SUMMARY { |
| 920 | if isCount(name) { |
| 921 | p.currentIsSummaryCount = true |
| 922 | } |
| 923 | if isSum(name) { |
| 924 | p.currentIsSummarySum = true |
| 925 | } |
| 926 | return |
| 927 | } |
| 928 | } |
| 929 | histogramName := histogramMetricName(name) |
| 930 | if p.currentMF = p.metricFamiliesByName[histogramName]; p.currentMF != nil { |
| 931 | if p.currentMF.GetType() == dto.MetricType_HISTOGRAM || |
| 932 | p.currentMF.GetType() == dto.MetricType_GAUGE_HISTOGRAM { |
| 933 | if isCount(name) { |
| 934 | p.currentIsHistogramCount = true |
| 935 | } |
| 936 | if isSum(name) { |
| 937 | p.currentIsHistogramSum = true |
| 938 | } |
| 939 | return |
| 940 | } |
| 941 | } |
| 942 | p.currentMF = &dto.MetricFamily{Name: proto.String(name)} |
| 943 | p.metricFamiliesByName[name] = p.currentMF |
| 944 | } |
| 945 | |
| 946 | func isValidLabelNameStart(b byte) bool { |
| 947 | return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' || b == '"' |
no test coverage detected