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

Method startTimestamp

expfmt/text_parse.go:474–496  ·  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

472// startTimestamp represents the state where the next byte read from p.buf is
473// the start of the timestamp (or whitespace leading up to it).
474func (p *TextParser) startTimestamp() stateFn {
475 if p.skipBlankTab(); p.err != nil {
476 return nil // Unexpected end of input.
477 }
478 if p.readTokenUntilWhitespace(); p.err != nil {
479 return nil // Unexpected end of input.
480 }
481 timestamp, err := strconv.ParseInt(p.currentToken.String(), 10, 64)
482 if err != nil {
483 // Create a more helpful error message.
484 p.parseError(fmt.Sprintf("expected integer as timestamp, got %q", p.currentToken.String()))
485 return nil
486 }
487 p.currentMetric.TimestampMs = proto.Int64(timestamp)
488 if p.readTokenUntilNewline(false); p.err != nil {
489 return nil // Unexpected end of input.
490 }
491 if p.currentToken.Len() > 0 {
492 p.parseError(fmt.Sprintf("spurious string after timestamp: %q", p.currentToken.String()))
493 return nil
494 }
495 return p.startOfLine
496}
497
498// readingHelp represents the state where the last byte read (now in
499// 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