Engineering
Usage Metering Best Practices: Designing Accurate, Idempotent Usage Events
By the Orvlin team · · 9 min read
Anatomy of a good usage event
- Unique transaction ID for deduplication.
- Customer or account identifier.
- Event timestamp (when usage happened, not when sent).
- Event type and typed properties such as model or region.
Idempotency is non-negotiable
Retries happen. Without deduplication by transaction ID, network retries become double charges.
Handling late and corrected data
Define a grace period before invoices finalize. For corrections after close, issue credits or adjustments rather than rewriting finalized invoices.
Make every number traceable
Finance and customers should be able to trace an invoice line back to the events behind it. Versioned aggregates make backfills safe.
Frequently asked questions
- Should I aggregate usage before sending it?
- Send raw events where possible. Pre-aggregation loses auditability and makes pricing changes harder.