docs: send numeric event values as strings in quickstart#4747
docs: send numeric event values as strings in quickstart#4747tothandras wants to merge 1 commit into
Conversation
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
📝 WalkthroughWalkthroughThe Quickstart ingestion examples now send ChangesQuickstart precision examples
Estimated code review effort: 1 (Trivial) | ~3 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| Note that numeric values where precision matters are sent as JSON strings | ||
| (`"duration_ms": "10"`) so they are parsed without floating-point precision | ||
| loss. |
There was a problem hiding this 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.
| 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!
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
quickstart/README.md
| Note that numeric values where precision matters are sent as JSON strings | ||
| (`"duration_ms": "10"`) so they are parsed without floating-point precision | ||
| loss. |
There was a problem hiding this comment.
🎯 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.
| 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.
Overview
The quickstart README's curl examples send
duration_msas 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_msvalues inquickstart/README.mdand 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
duration_msvalues as JSON strings.Greptile Summary
This PR updates numeric values in the quickstart event examples. The main changes are:
duration_msvalues as JSON strings.Confidence Score: 5/5
The examples remain usable, but the new precision guidance should be corrected.
quickstart/README.md
Important Files Changed
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "docs: send numeric event values as strin..." | Re-trigger Greptile
Context used: