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

Function parseSampleTimestampMs

expfmt/openmetrics_parse.go:1023–1033  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

1021}
1022
1023func parseSampleTimestampMs(s string) (int64, error) {
1024 f, err := parseOpenMetricsFloat(s)
1025 if err != nil {
1026 return 0, err
1027 }
1028 ms := math.Round(f * 1000)
1029 if math.IsNaN(ms) || math.IsInf(ms, 0) || ms < float64(math.MinInt64) || ms >= math.Exp2(63) {
1030 return 0, fmt.Errorf("invalid timestamp %v", f)
1031 }
1032 return int64(ms), nil
1033}
1034
1035func parseTimestampToProto(s string) (*timestamppb.Timestamp, error) {
1036 if ts, ok := parseExactDecimalTimestamp(s); ok {

Callers 2

handleSampleMethod · 0.85
handleSampleMethod · 0.85

Calls 1

parseOpenMetricsFloatFunction · 0.85

Tested by

no test coverage detected