Repository navigation
[AISAGE-503] feat(usage): instrument usage writes and queue processing - #8121
Conversation
6518e4f to
bc646a5
Compare
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryFull-diff review of 18 files found no new issues: caller context is allowlisted and never logged raw, completion logging preserves write results and exceptions, sampling is bounded and documented, and the previously raised test/doc suggestions are addressed. Files Reviewed (18 files)
Previous Review Summaries (2 snapshots, latest commit 52ee6cb)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 52ee6cb)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe instrumentation logic is sound; the remaining findings are low-risk test-coverage and documentation-accuracy gaps in the new telemetry tests and staging runbook. Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (18 files)
Fix these issues in Kilo Cloud Previous review (commit bc646a5)Status: 2 Issues Found | Recommendation: Address before merge Executive SummaryThe instrumentation changes are functionally sound; both findings are low-risk accuracy issues in a documentation claim and a test assertion. Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (18 files)
Reviewed by deepseek-v4.1-flash-1017 · Input: 125.5K · Output: 33K · Cached: 2.3M Review guidance: REVIEW.md from base branch |
bc646a5 to
52ee6cb
Compare
52ee6cb to
e4db768
Compare
Summary
Instrument usage persistence and queue processing with structured logs for ongoing diagnosis and log-derived counts and latency. Emit completion events at the shared persistence boundary with outcome, monotonic duration, event age, execution region and finite entrypoint/caller context. Keep staging completions and all failures at 100%; sample production recorded/duplicate completions uniformly at 1%, including
sample_ratefor estimated attempt counts. Add matching severity, acknowledgement/retry action, queue wait and separate writer-attempt timing to consumer logs.Keep Worker logs in Cloudflare and document the lasting field contract. Only the usage-ingest consumer opts into the queue caller marker; classifier and benchmark writers keep their original headers and an unknown caller. Caller markers are diagnostic only and older clients remain compatible. Completion labels describe the actual persistence path; queue-only fallbacks require deployment flag context and the existing fallback warning. External log export remains off.
These signals also support direct-versus-queued staging load-test comparisons. Include a staging validation guide with read-only database snapshots to help evaluate that use case.
Verification
Visual Changes
N/A
Reviewer Notes
Passed 140 focused handler/shared/client tests and 63 usage-ingest tests, including runtime tests, plus 458 auto-routing, 66 affected benchmark and 865 Worker-utils tests. Shared-package, Worker-utils, service and scoped writer-route typechecks, type-aware lint, formatting and generated Worker types pass.
Handler tests invoke the actual Next POST handler with mocked persistence; Worker runtime tests use emulated Queues and a fake writer. No hosted load test or DB snapshot execution was performed. Estimate completion attempt counts with
sum(1 / sample_rate); sampled distinct IDs cannot establish exact completeness. Consumer logs remain at 100%, and existing slow phase diagnostics are unchanged. Hosted ingestion/sampling and exact persisted-row reconciliation remain separate operational concerns.