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

Method startTimestamp

expfmt/text_parse.go:620–642  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

618// startTimestamp represents the state where the next byte read from p.buf is
619// the start of the timestamp (or whitespace leading up to it).
620func (p *TextParser) startTimestamp() stateFn {
621 if p.skipBlankTab(); p.err != nil {
622 return nil // Unexpected end of input.
623 }
624 if p.readTokenUntilWhitespace(); p.err != nil {
625 return nil // Unexpected end of input.
626 }
627 timestamp, err := strconv.ParseInt(p.currentToken.String(), 10, 64)
628 if err != nil {
629 // Create a more helpful error message.
630 p.parseError(fmt.Sprintf("expected integer as timestamp, got %q", p.currentToken.String()))
631 return nil
632 }
633 p.currentMetric.TimestampMs = proto.Int64(timestamp)
634 if p.readTokenUntilNewline(false); p.err != nil {
635 return nil // Unexpected end of input.
636 }
637 if p.currentToken.Len() > 0 {
638 p.parseError(fmt.Sprintf("spurious string after timestamp: %q", p.currentToken.String()))
639 return nil
640 }
641 return p.startOfLine
642}
643
644// readingHelp represents the state where the last byte read (now in
645// p.currentByte) is the first byte of the docstring after 'HELP'.

Callers

nothing calls this directly

Calls 6

skipBlankTabMethod · 0.95
parseErrorMethod · 0.95
readTokenUntilNewlineMethod · 0.95
StringMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected