readingType represents the state where the last byte read (now in p.currentByte) is the first byte of the type hint after 'HELP'.
()
| 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'. |
| 515 | func (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. |
nothing calls this directly
no test coverage detected