()
| 680 | } |
| 681 | |
| 682 | func (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 | |
| 720 | func isValidLabelNameStart(b byte) bool { |
| 721 | return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') || b == '_' |
no test coverage detected