Menu

Which requests end up on the bill? Tracing usage rows from a Hono app and a FastAPI container
📰

Which requests end up on the bill? Tracing usage rows from a Hono app and a FastAPI container

DEV Community: fastapi·Jack Ma·4 days ago
#EgnGSAXJ
#devtofastapi#devto#dev#count#units
Long article (1497 words) — no AI summary yet.
Reading 0:00
15s threshold

In both tests below, successful word-count requests added billable units. A request that called track() and then returned 422 added zero, and so did rate-limited ones. A health check produced no row at all. I also checked when each SDK sent its last rows during shutdown.

For Hono I used the @usagerail/node usage metering SDK on JSR (0.1.2). For FastAPI I ran the FastAPI starter image on Docker Hub (0.1.0, with Python SDK 0.1.1). For looking up a customer's recorded usage afterwards, the Postman collection for UsageRail's usage-based billing API has a "Get usage" request.

Nothing here talked to the real service. Both SDKs accept a base URL ( baseUrl in Node, base_url in Python), so I pointed them at a 36-line local stub. It answers the three endpoints the SDK calls ( /v1/sync , /v1/leases , /v1/ingest ) with the shapes from the package's protocol module and prints every usage row it receives.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.