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

Struct TextParser

expfmt/text_parse.go:55–86  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

53// TextParser instances must be created with NewTextParser, the zero value of
54// TextParser is invalid.
55type 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.
89func NewTextParser(nameValidationScheme model.ValidationScheme) TextParser {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected