Skip to content

Format negative Timestamp values with one leading sign - #1229

Open
Harshil-1603 wants to merge 1 commit into
prometheus:masterfrom
Harshil-1603:fix/negative-timestamp-format
Open

Harshil-1603 wants to merge 1 commit into
prometheus:masterfrom
Harshil-1603:fix/negative-timestamp-format

Conversation

@Harshil-1603

Copy link
Copy Markdown

str(Timestamp(-123, 456000000)) currently returns -123.-456000000. OpenMetrics exposition writes that malformed number into the scrape, even though float(timestamp) correctly returns -123.456.

Render one leading sign and absolute seconds/nanoseconds, retaining nine fractional digits. Cover small and large fractions, zero nanoseconds, negative values whose stored seconds truncate to zero, and negative Timestamp objects in the existing OpenMetrics exposition test.

Validation on CPython 3.12.13:

  • The new negative-fraction cases and exposition assertion fail before the fix.
  • Full suite: 439 passed, 5 skipped, plus 32 subtests passed, with benchmark timing disabled. The skips concern unavailable optional integrations.
  • Full-tree flake8, isort, mypy, and git diff --check pass.

@csmarchbanks This is a small formatting fix; the commit includes the DCO sign-off. Prepared and tested with OpenAI Codex assistance; no human review is claimed.

Signed-off-by: Harshil <181649964+Harshil-1603@users.noreply.github.com>

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant