Skip to content

feat: report quota exhaustion as its own quota_exceeded metrics event (1.7.3) - #81

Merged
Starllordz merged 1 commit into
mainfrom
feature/quota-exceeded-event
Nov 3, 2026
Merged

Starllordz merged 1 commit into
mainfrom
feature/quota-exceeded-event

Conversation

@Starllordz

@Starllordz Starllordz commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

What

When a command stops because the Lara plan quota is exhausted, metrics now queue a dedicated event:

{ "eventType": "quota_exceeded", "latencyMs": ..., "charsTranslated": ..., "metadata": { ... } }

instead of call_error with errorType: "quota_exceeded".

Why

Running out of plan characters is not the CLI failing. Keeping it out of call_error lets the error funnel count only real failures, and makes quota exhaustion trackable on its own.

Details

  • finishCommand (src/modules/metrics/metrics.ts) reuses errorTypeFor, so quota errors wrapped as cause (e.g. the HandledExitError thrown in translate.ts) are still detected, and a quota error is not buried by a later generic error.
  • Metadata is unchanged (command, feature, exitCode, httpStatus, laraErrorType, …). errorType is omitted on the new event.
  • auth_fail is unaffected (quota never arrives as 401/403).
  • README metrics section documents the new event; version bumped to 1.7.3 (patch).

Before merging

The metrics ingestion backend must accept eventType: "quota_exceeded" for the cli channel. If it validates event types against a closed list, it would reject the whole batch the event rides in.

Tests

  • New finishCommand tests: quota error → quota_exceeded with no errorType; quota error followed by a generic unwind error → still quota_exceeded.
  • pnpm test (981 passing), pnpm run build, ESLint and Prettier on touched files.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The deployed metrics backend’s support for quota_exceeded on the cli channel remains unverified, and an HTTP 400 rejection would discard the entire queued batch, including unrelated events.

No open issues 🎉

What changed in this PR

This PR separates plan quota exhaustion from CLI failures in metrics, introducing a dedicated quota_exceeded event for version 1.8.0.

Changes:

  • Emit quota_exceeded without errorType, preserving shared event metadata.
  • Add tests for direct quota errors and quota errors followed by generic unwind errors.
  • Document the event and bump the version to 1.8.0.

The metrics ingestion backend must accept the new event type before merging.

File Description
src/​modules/​metrics/​metrics.ts Emit a dedicated event for quota exhaustion.
src/​__tests__/​modules/​metrics.test.ts Test quota event classification and omission of errorType.
README.md Document the new event and update the version badge.
package.json Bump the package version to 1.8.0.

Review effort: Balanced

@Starllordz
Starllordz requested a balanced review from Copilot November 3, 2026 14:52
@Starllordz Starllordz changed the title feat: report quota exhaustion as its own quota_exceeded metrics event (1.8.0) feat: report quota exhaustion as its own quota_exceeded metrics event (1.7.3) Nov 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The package version remains 1.7.3 despite the specified 1.8.0 release, and the README badge also needs alignment.

1 open issue

Review effort: Balanced

Comment thread package.json Resolved
… (1.7.3)

A plan running out of characters is not the CLI failing. Commands that stop
on an exhausted quota now queue eventType 'quota_exceeded' instead of
'call_error' with errorType 'quota_exceeded', so the error funnel only
counts real failures. Metadata is unchanged.
@Starllordz
Starllordz force-pushed the feature/quota-exceeded-event branch from fd051f1 to 8009dfa Compare November 3, 2026 15:30
@Starllordz
Starllordz merged commit 2654eeb into main Nov 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants