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

Method startOfLine

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

Callers 1

Calls 1

skipBlankTabMethod · 0.95

Tested by 1