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

Method readingType

expfmt/text_parse.go:515–531  ·  view source on GitHub ↗

readingType represents the state where the last byte read (now in p.currentByte) is the first byte of the type hint after 'HELP'.

()

Source from the content-addressed store, hash-verified

513// readingType represents the state where the last byte read (now in
514// p.currentByte) is the first byte of the type hint after 'HELP'.
515func (p *TextParser) readingType() stateFn {
516 if p.currentMF.Type != nil {
517 p.parseError(fmt.Sprintf("second TYPE line for metric name %q, or TYPE reported after samples", p.currentMF.GetName()))
518 return nil
519 }
520 // Rest of line is the type.
521 if p.readTokenUntilNewline(false); p.err != nil {
522 return nil // Unexpected end of input.
523 }
524 metricType, ok := dto.MetricType_value[strings.ToUpper(p.currentToken.String())]
525 if !ok {
526 p.parseError(fmt.Sprintf("unknown metric type %q", p.currentToken.String()))
527 return nil
528 }
529 p.currentMF.Type = dto.MetricType(metricType).Enum()
530 return p.startOfLine
531}
532
533// parseError sets p.err to a ParseError at the current line with the given
534// message.

Callers

nothing calls this directly

Calls 3

parseErrorMethod · 0.95
readTokenUntilNewlineMethod · 0.95
StringMethod · 0.65

Tested by

no test coverage detected