TextParser is used to parse the simple and flat text-based exchange format. Its zero value is ready to use.
| 51 | // TextParser is used to parse the simple and flat text-based exchange format. Its |
| 52 | // zero value is ready to use. |
| 53 | type TextParser struct { |
| 54 | metricFamiliesByName map[string]*dto.MetricFamily |
| 55 | buf *bufio.Reader // Where the parsed input is read through. |
| 56 | err error // Most recent error. |
| 57 | lineCount int // Tracks the line count for error messages. |
| 58 | currentByte byte // The most recent byte read. |
| 59 | currentToken bytes.Buffer // Re-used each time a token has to be gathered from multiple bytes. |
| 60 | currentMF *dto.MetricFamily |
| 61 | currentMetric *dto.Metric |
| 62 | currentLabelPair *dto.LabelPair |
| 63 | |
| 64 | // The remaining member variables are only used for summaries/histograms. |
| 65 | currentLabels map[string]string // All labels including '__name__' but excluding 'quantile'/'le' |
| 66 | // Summary specific. |
| 67 | summaries map[uint64]*dto.Metric // Key is created with LabelsToSignature. |
| 68 | currentQuantile float64 |
| 69 | // Histogram specific. |
| 70 | histograms map[uint64]*dto.Metric // Key is created with LabelsToSignature. |
| 71 | currentBucket float64 |
| 72 | // These tell us if the currently processed line ends on '_count' or |
| 73 | // '_sum' respectively and belong to a summary/histogram, representing the sample |
| 74 | // count and sum of that summary/histogram. |
| 75 | currentIsSummaryCount, currentIsSummarySum bool |
| 76 | currentIsHistogramCount, currentIsHistogramSum bool |
| 77 | } |
| 78 | |
| 79 | // TextToMetricFamilies reads 'in' as the simple and flat text-based exchange |
| 80 | // format and creates MetricFamily proto messages. It returns the MetricFamily |
nothing calls this directly
no outgoing calls
no test coverage detected