Skip to content

docs: send numeric event values as strings in quickstart#4747

Open
tothandras wants to merge 1 commit into
mainfrom
claude/quickstart-numbers-as-strings
Open

docs: send numeric event values as strings in quickstart#4747
tothandras wants to merge 1 commit into
mainfrom
claude/quickstart-numbers-as-strings

Conversation

@tothandras

@tothandras tothandras commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Overview

The quickstart README's curl examples send duration_ms as a JSON number ("duration_ms": 10), while the quickstart test (quickstart/quickstart_test.go) and the docs best-practices guidance both use string-quoted numbers to preserve precision.

This quotes the three duration_ms values in quickstart/README.md and adds a one-line note explaining the convention: numeric values where precision matters should be sent as JSON strings so they are parsed without floating-point precision loss.

Notes for reviewer

Docs-only change; no code affected. The openmeter.io docs quickstarts are being aligned to the same convention separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_014TWiAB8V1mxpGjpfFVMUaw


Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated Quickstart usage-event examples to represent duration_ms values as JSON strings.
    • Added guidance to use JSON strings when numeric precision is important, helping prevent floating-point precision loss.

Greptile Summary

This PR updates numeric values in the quickstart event examples. The main changes are:

  • Sends all three duration_ms values as JSON strings.
  • Adds a note claiming that strings avoid floating-point precision loss.

Confidence Score: 5/5

The examples remain usable, but the new precision guidance should be corrected.

  • Quoted numeric values are accepted by the event parser.
  • Both quoted and unquoted values still pass through float64 under the quickstart defaults.
  • The issue is limited to misleading documentation.

quickstart/README.md

Important Files Changed

Filename Overview
quickstart/README.md Quotes three event values and adds a precision claim that does not hold under the quickstart's float64 parsing path.

Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
quickstart/README.md:48-50
**Quoted Values Still Lose Precision**

When a value exceeds float64's exact range, quoting it does not prevent precision loss: numeric strings are parsed with `strconv.ParseFloat(..., 64)`, and the default query path converts them with `toFloat64OrNull`. The note therefore promises protection that the quickstart configuration does not provide.

```suggestion
Numeric event values may also be sent as JSON strings, as shown here
(`"duration_ms": "10"`).
```

Reviews (1): Last reviewed commit: "docs: send numeric event values as strin..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used:

  • Context used - CLAUDE.md (source)

The quickstart curl examples sent duration_ms as a JSON number, while the
quickstart test and the docs best practices use string-quoted numbers to
preserve precision. Quote the values and note the convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014TWiAB8V1mxpGjpfFVMUaw
@tothandras
tothandras requested a review from a team as a code owner July 18, 2026 20:39
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Quickstart ingestion examples now send duration_ms as JSON strings and explain that precision-sensitive numeric values should use strings to avoid floating-point precision loss.

Changes

Quickstart precision examples

Layer / File(s) Summary
Update duration encoding examples
quickstart/README.md
All three CloudEvents examples encode duration_ms as JSON strings, and the first example adds precision guidance.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: galexihu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the documentation update to send quickstart event values as strings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/quickstart-numbers-as-strings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread quickstart/README.md
Comment on lines +48 to +50
Note that numeric values where precision matters are sent as JSON strings
(`"duration_ms": "10"`) so they are parsed without floating-point precision
loss.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Quoted Values Still Lose Precision

When a value exceeds float64's exact range, quoting it does not prevent precision loss: numeric strings are parsed with strconv.ParseFloat(..., 64), and the default query path converts them with toFloat64OrNull. The note therefore promises protection that the quickstart configuration does not provide.

Suggested change
Note that numeric values where precision matters are sent as JSON strings
(`"duration_ms": "10"`) so they are parsed without floating-point precision
loss.
Numeric event values may also be sent as JSON strings, as shown here
(`"duration_ms": "10"`).

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: quickstart/README.md
Line: 48-50

Comment:
**Quoted Values Still Lose Precision**

When a value exceeds float64's exact range, quoting it does not prevent precision loss: numeric strings are parsed with `strconv.ParseFloat(..., 64)`, and the default query path converts them with `toFloat64OrNull`. The note therefore promises protection that the quickstart configuration does not provide.

```suggestion
Numeric event values may also be sent as JSON strings, as shown here
(`"duration_ms": "10"`).
```

**Context Used:** AGENTS.md ([source](https://app.greptile.com/openmeter/github/openmeterio/openmeter/-/custom-context?memory=eb020e3b-8e3b-45ea-a8b7-4006b2b2065b))

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@quickstart/README.md`:
- Around line 48-50: Update the numeric-value note in the README to state that
JSON strings avoid precision loss during JSON decoding, without implying that
precision is preserved through ingestion. Keep the example and parsing guidance
intact, but narrow the claim to the decoding stage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 88c39923-73a7-4d31-bdcf-0cf7f63502bc

📥 Commits

Reviewing files that changed from the base of the PR and between 3885445 and bb40120.

📒 Files selected for processing (1)
  • quickstart/README.md

Comment thread quickstart/README.md
Comment on lines +48 to +50
Note that numeric values where precision matters are sent as JSON strings
(`"duration_ms": "10"`) so they are parsed without floating-point precision
loss.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Narrow the precision claim.

The ingestion parser accepts these strings but ultimately converts them to float64 (openmeter/meter/parse.go:116-129), so arbitrary-precision values can still lose precision. Please say this avoids precision loss during JSON decoding, rather than implying end-to-end precision preservation.

Suggested wording
-Note that numeric values where precision matters are sent as JSON strings
-(`"duration_ms": "10"`) so they are parsed without floating-point precision
-loss.
+Note that numeric values where precision matters are sent as JSON strings
+(`"duration_ms": "10"`) to avoid precision loss during JSON decoding.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Note that numeric values where precision matters are sent as JSON strings
(`"duration_ms": "10"`) so they are parsed without floating-point precision
loss.
Note that numeric values where precision matters are sent as JSON strings
(`"duration_ms": "10"`) to avoid precision loss during JSON decoding.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@quickstart/README.md` around lines 48 - 50, Update the numeric-value note in
the README to state that JSON strings avoid precision loss during JSON decoding,
without implying that precision is preserved through ingestion. Keep the example
and parsing guidance intact, but narrow the claim to the decoding stage.

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.

2 participants