TextParser is used to parse the simple and flat text-based exchange format. TextParser instances must be created with NewTextParser, the zero value of TextParser is invalid.
| 53 | // TextParser instances must be created with NewTextParser, the zero value of |
| 54 | // TextParser is invalid. |
| 55 | type TextParser struct { |
| 56 | metricFamiliesByName map[string]*dto.MetricFamily |
| 57 | buf *bufio.Reader // Where the parsed input is read through. |
| 58 | err error // Most recent error. |
| 59 | lineCount int // Tracks the line count for error messages. |
| 60 | currentByte byte // The most recent byte read. |
| 61 | currentToken bytes.Buffer // Re-used each time a token has to be gathered from multiple bytes. |
| 62 | currentMF *dto.MetricFamily |
| 63 | currentMetric *dto.Metric |
| 64 | currentLabelPair *dto.LabelPair |
| 65 | currentLabelPairs []*dto.LabelPair // Temporarily stores label pairs while parsing a metric line. |
| 66 | |
| 67 | // The remaining member variables are only used for summaries/histograms. |
| 68 | currentLabels map[string]string // All labels including '__name__' but excluding 'quantile'/'le' |
| 69 | // Summary specific. |
| 70 | summaries map[uint64]*dto.Metric // Key is created with LabelsToSignature. |
| 71 | currentQuantile float64 |
| 72 | // Histogram specific. |
| 73 | histograms map[uint64]*dto.Metric // Key is created with LabelsToSignature. |
| 74 | currentBucket float64 |
| 75 | // These tell us if the currently processed line ends on '_count' or |
| 76 | // '_sum' respectively and belong to a summary/histogram, representing the sample |
| 77 | // count and sum of that summary/histogram. |
| 78 | currentIsSummaryCount, currentIsSummarySum bool |
| 79 | currentIsHistogramCount, currentIsHistogramSum bool |
| 80 | // These indicate if the metric name from the current line being parsed is inside |
| 81 | // braces and if that metric name was found respectively. |
| 82 | currentMetricIsInsideBraces, currentMetricInsideBracesIsPresent bool |
| 83 | // scheme sets the desired ValidationScheme for names. Defaults to the invalid |
| 84 | // UnsetValidation. |
| 85 | scheme model.ValidationScheme |
| 86 | } |
| 87 | |
| 88 | // NewTextParser returns a new TextParser with the provided nameValidationScheme. |
| 89 | func NewTextParser(nameValidationScheme model.ValidationScheme) TextParser { |
nothing calls this directly
no outgoing calls
no test coverage detected