fix(basket): stop logging expected conditions as errors in Axiom - #590
Conversation
Expected 4xx conditions (quota exceeded, rate limits, invalid client IDs) were logged at error level because the evlog elysia plugin logs every thrown error as error and drops the status. Derive the client error message set from the error catalog and downgrade those events to warn in the drain, keyed on http_status or the catalog message.
The fallback recovers the delivery via direct ClickHouse insert, so a connection failure that is handled should not surface as an error in Axiom. Log it via log.warn and assert the new channel in the test.
|
The latest updates on your projects. Learn more about Unkey Deploy
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
Greptile SummaryThe PR reduces noisy Basket error telemetry by classifying known 4xx conditions and recoverable Redpanda connection failures as warnings.
Confidence Score: 5/5The PR appears safe to merge, with recoverable and expected conditions downgraded without suppressing downstream fallback-insert failures. The normalization is limited to error-level events with numeric 4xx statuses or messages derived from the structured 4xx catalog, while unknown and server-side errors retain their level; failed ClickHouse fallback inserts continue to be captured as errors. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
E[Basket telemetry event] --> N[Normalize for Axiom]
N --> C{Error level and client 4xx?}
C -->|Yes| W[Emit warning with client_http_error]
C -->|No| K[Preserve existing level]
R[Redpanda connection failure] --> F[Select direct ClickHouse fallback]
F --> L[Emit warning]
F --> I{ClickHouse insert succeeds?}
I -->|Yes| S[Delivery completes]
I -->|No| X[Capture fallback failure as error]
Reviews (1): Last reviewed commit: "fix(basket): log redpanda to clickhouse ..." | Re-trigger Greptile |
…log-axiom Move the batched Axiom drain, HTTP enrichers, string/duration normalization, and the client-error downgrade into a shared module so basket (and future services) reuse them. Basket keeps its catalog-driven client-error detection and delegates the mechanics to the shared helpers.
What
Follow-up to #589. Basket's Axiom error signal is ~100% noise: of 3.18M weekly
level=errorevents, 3,169,529 (99.7%) areEvent quota exceeded— a normal billing state (customer hit their plan limit). Rate limits, invalid client IDs, unauthorized origins, and a handled Redpanda→ClickHouse fallback are also logged as errors. Real errors (e.g.Failed to get website by ID, 135/wk) are drowned ~20,000:1, making error-rate alerting meaningless.Root cause
The
evlogElysia plugin logs every thrown error viastate.logger.error(err)and drops the error's status. Basket'sonErrormarks 4xx asisExpectedClientErrorbut doesn't downgrade the already-set level, and the drain's old 4xx→warn check keyed offerror.status, which is gone by drain time (onlyerror_messagesurvives).Fix
structured-errors.tsand deriveCLIENT_ERROR_MESSAGES(messages with 4xx status) from it. The Axiom drain downgradeserror → warn(+client_http_error) whenhttp_statusis 4xx orerror_messageis a known catalog client error. Ordering-independent — keys only off fields that survive to the drain.log.warn, notcaptureError.Test
New
evlog-basket.test.tscovers the downgrade matrix (catalog 4xx → warn,http_status4xx → warn, 5xx catalog stays error, unknown stays error, string-error flattening). Full basket suite: 606 pass (vitest run);check-typesgreen.Follow-up
Once deployed, basket's error-rate panels/alerts will reflect real failures instead of quota noise.
Summary by cubic
Downgraded expected client HTTP errors to warn in Axiom and reclassified the Redpanda→ClickHouse fallback as warn, so Basket’s error signal reflects real failures instead of quota noise. Extracted Axiom drain helpers to
@databuddy/shared/evlog-axiomand adopted them in Basket.Bug Fixes
warn(+client_http_error) in the Axiom drain whenhttp_statusis 4xx orerror_messagematches client errors derived from the catalog.errorintoerror_messagebefore classification for consistent handling.log.warnfor the handled Redpanda connection failure that falls back to direct ClickHouse insert.Refactors
@databuddy/shared/evlog-axiomand switched Basket to use them.downgradeClientHttpErrorafter normalization.Written for commit 021e11e. Summary will update on new commits.