Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextFormatUtil.writeTimestamp writes a value with a decimal point but the spec specifies an int64 #1277

Open
garthy opened this issue Feb 18, 2025 · 1 comment · May be fixed by #1292
Open

Comments

@garthy
Copy link

garthy commented Feb 18, 2025

The method here https://github.com/prometheus/client_java/blob/7016bf7c5749e806ef91a918fdb294d394b83a16/prometheus-metrics-exposition-textformats/src/main/java/io/prometheus/metrics/expositionformats/TextFormatUtil.java#L24C15-L35

static void writeTimestamp(Writer writer, long timestampMs) throws IOException {
    writer.write(Long.toString(timestampMs / 1000L));
    writer.write(".");

Writes a decimal point.

The spec https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details

specifies the timestamp as an int64

The timestamp is an int64 (milliseconds since epoch, i.e. 1970-01-01 00:00:00 UTC, excluding leap seconds), represented as required by Go's [ParseInt()](https://golang.org/pkg/strconv/#ParseInt) function.

This causes Prometheus/promtool to error on metrics with a timestamp

error while linting: text format parsing error in line 17: expected integer as timestamp, got "1739889638.000"
@zeitlinger
Copy link
Member

@fstab do you have an idea why we might have added the decimal point?

@zeitlinger zeitlinger linked a pull request Feb 27, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants