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

Method startOfLine

expfmt/text_parse.go:195–220  ·  view source on GitHub ↗

startOfLine represents the state where the next byte read from p.buf is the start of a line (or whitespace leading up to it).

()

Source from the content-addressed store, hash-verified

193// startOfLine represents the state where the next byte read from p.buf is the
194// start of a line (or whitespace leading up to it).
195func (p *TextParser) startOfLine() stateFn {
196 p.lineCount++
197 p.currentMetric = nil
198 p.currentMetricIsInsideBraces = false
199 p.currentMetricInsideBracesIsPresent = false
200 if p.skipBlankTab(); p.err != nil {
201 // This is the only place that we expect to see io.EOF,
202 // which is not an error but the signal that we are done.
203 // Any other error that happens to align with the start of
204 // a line is still an error.
205 if errors.Is(p.err, io.EOF) {
206 p.err = nil
207 }
208 return nil
209 }
210 switch p.currentByte {
211 case '#':
212 return p.startComment
213 case '\n':
214 return p.startOfLine // Empty line, start the next one.
215 case '{':
216 p.currentMetricIsInsideBraces = true
217 return p.readingLabels
218 }
219 return p.readingMetricName
220}
221
222// startComment represents the state where the next byte read from p.buf is the
223// start of a comment (or whitespace leading up to it).

Callers 1

Calls 1

skipBlankTabMethod · 0.95

Tested by 1