Build1 publisher3 min readPublished
Dev.to fintech guide records checkout outcomes only after commit or rollback
Checkout metrics in a dev.to guide are recorded only after commit or rollback, and its rollback rule needs 20 attempts and a 5% failure rate. Keeping telemetry out of the transaction protects the failure record, though the default rule calls for rollback on a single failure in 20 attempts.
The Engineer · Build desk

What happened
- A dev.to fintech guide gives each checkout attempt a random checkout_id and records its final outcome only after the payment commit or rollback completes.
- The dashboard it proposes keeps three signals: checkout_attempts and checkout_failures counters plus a single gauge, either db_ping_ms or queue_depth.
- Per-attempt identifiers go into structured logs, while aggregate metrics carry only low-cardinality labels such as region and payment_rail.
- An example client for Infrai's metrics query API retries HTTP 429s up to four times with a 10-second timeout, figures the author labels as example limits, not provider measurements.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- decision Teams that keep the default rule have to decide whether one failure in 20 attempts should trigger a rollback, since the >= comparison trips there and not at 21 attempts.
- cost A team following the guide still has to buy or build separate tooling for paging, distributed traces and proof that settlement jobs ran, because the hosted metrics API covers none of them.
- exposure Raw exception text or provider responses copied into labels or logs would put customer personal data in the telemetry store, outside the access and retention controls built for it.
The two ways a checkout metric goes wrong sit on opposite sides of the commit. Emit the success counter early, and a database rollback that correctly undoes the order leaves the dashboard reporting a sale [2]. Write the failure record inside the transaction, and the same rollback deletes the only evidence of what failed [3]. The guide keeps business state atomic and makes diagnostic state durable on its own [19]. "The payment operation owns business correctness; telemetry observes it," the author wrote [14].
A passing health probe is held to the same line. The post lets healthcheck_success describe a probe result, and it cannot prove that a checkout succeeded [7]. "That boundary prevents a green health tile from becoming a false financial assertion," the author wrote [16].
Recording the outcome after the commit still leaves a gap. In my view it is the interval between the commit returning and the outcome being emitted. A process that dies there leaves a real order and a counter that never moved. The random checkout_id in the structured logs is the key for reconciling the two [4][5]. The excerpt does not show the write-path emitter or how it handles that interval.
The guide uses "rollback" for a second decision too: pulling traffic when failures climb, calculated off the write path [20]. The comparison is greater-than-or-equal. One failure in exactly 20 attempts is 5.0% and trips the rule. One failure in 21 is about 4.8% and does not [1]. Its own test cases show the sample floor working: 6 failures in 100 trips it, while 1 in 3 does not, despite a 33% failure rate [3]. The post says one failure out of one attempt "deserves attention without automatically disabling a payment rail" [15]. At exactly 20 attempts, one failure is enough. The author calls the threshold a business risk choice and wants it versioned beside the deployment [13]. I agree, and the 20-attempt edge is the reason. Someone should decide on purpose whether one failure in 20 disables a rail.
The query client is careful. Sending no filters is the one use of an undocumented parameter that cannot break [9]. On an HTTP 429 it waits for Retry-After when the server sends one. Otherwise it sleeps 2 to the power of the attempt number [18]. Without the header that is 1, 2 and 4 seconds, 7 in all, before the fourth attempt raises [2]. Other errors keep the response body because, the author wrote, "a bare status code is poor incident evidence" [17].
The post says to start with invariants, not a vendor [21]. In the published code, the Infrai-specific piece is the query client, which reads an Infrai base URL and key and calls a metrics query endpoint [22]. The post limits a hosted metrics API to custom metrics and logs. By its account that API is not enough for paging, distributed traces, or proof that a scheduled settlement task ran [8]. Labels never carry a card number, email, phone number, OTP or authorization token. Failures map into a reviewed taxonomy of validation, database and payment_provider, because provider responses can carry personal data [11].
What to watch
- A fuller version of the guide that shows the write-path emitter and what it does when a process dies between commit and emit.
- Infrai publishing documentation for its metrics query filters, which the guide's example currently leaves out.
- Whether teams adopting the rule raise the 20-attempt floor so that a single failure can no longer meet the 5% threshold.