Skip to content

[BUG] One batch evaluate call floods the Decision Audit with per-entry events #402

Description

@prajjwalkumar17

Summary

One evaluation call recorded one analytics event per batch entry, so the Decision Audit listed 30–52 "events" for a payment the router had called three times. Healthy batching read as a call storm, and the noise buried the routing mismatches the screen exists to surface. Traced on sandbox (pay_OR9TzfVd6AuKV8y7I9A8): three calls inside 31 ms batching 3, 7 and 7 entries → 3 request-hits + 17 per-entry events, before confirm or a checkout refresh added theirs.

Fix — in two steps

  1. feat(analytics): count evaluation calls in the Decision Audit, not per-entry events #387 added call_count = uniq(request_id) beside event_count (Matches row reading 3 calls · 17 entries, per-call collapsible trace groups keyed on request_id) — at the cost of a ClickHouse column, migration 039, and column-drift probe machinery. It also fixed two things found on the way: an empty batch answered TE_04 400 — making every session/PML call from a card-only cut-over profile a logged failure plus a single-call retry — and now answers 200 {"results": []}; and POST /routing/evaluate/batch gained its missing classify_request arm so batch calls appear in the request-level audit at all.
  2. revert(analytics): drop the call-count column and its migration machinery #390 + feat(analytics): one preview event per batch evaluate call #391 made the schema machinery unnecessary and removed it: a batch call now records one preview event per call — per-entry outcomes (pm type, status, gateway, rule name; stage + error for failures) ride in the event's details (~3 KB for a 12-entry batch vs the 64 KB truncation cap), payment_id is preserved when uniform across entries so audit lookup by payment id still lands, and any failed entry makes the call's status error. A 12-entry batch: 13 events before → 2 after. Event counts are proportional to calls again with no schema change and nothing to run on existing deployments — and the two ride-along fixes from feat(analytics): count evaluation calls in the Decision Audit, not per-entry events #387 are restored (the restored empty-batch arm even failed to compile against a plain revert, which is why feat(analytics): one preview event per batch evaluate call #391 targets the revert branch).

Verified A/B against main's binary with live ClickHouse; positional contract held in every batch response; routing + analytics Playwright suites 29/29 against the patched build.

PRs

Part of #395.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions