Skip to content

feat(telemetry): record each CLI usage error by name and kind - #4973

Merged
dan-petty merged 2 commits into
mainfrom
feat/4839-usage-error-capture
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
feat/4839-usage-error-capture

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

No record showed which command names and options people and agents try and fail. The root group of the CLI now records each usage error of Click, also of a help query, a dry run and an MCP tool call, and raises it again, so the error box and exit code 2 do not change. Click's error types give the kind, and the group and command classes of new_typer() mark an unknown command word and an extra argument. One record goes to devops_cli_usage_error_total (labels kind, command_path and caller), to the log record cli_usage_error and to one line of usage-errors.jsonl under the user data root. A word that is not in the form of a CLI name is recorded as , and no record holds an argument value. The detect-agent library names the caller agent, and the implement job sets AI_AGENT=devops-implement. The setting telemetry.usage_ledger turns the ledger off.

Closes #4839

Change: openspec/changes/archive/2026-11-12-4839-record-each-cli-usage-error-by/

The root group of the CLI records each usage error of Click by kind,
command path and typed name, and raises it again, so the error box and
exit code 2 stay the same. The record goes to devops_cli_usage_error_total,
the cli_usage_error log record and usage-errors.jsonl under the user data
root. A word that is not in the form of a CLI name is recorded as <value>.
@dan-petty dan-petty added type/feature Type feature: a new function scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Local checks before the push (branch rebased on origin/main at 87ae9ee):

  • uv run devops ci --check --only lint,format,docs,startup-imports,swallowed-failures,openspec: all 7 rows pass. The startup-import budget holds: the hook classes import only modules that Typer already loads, and the record module loads only on an error.
  • uv run mypy on the 9 changed source files: no issues.
  • tests/telemetry/test_usage_errors.py: 33 passed. The snapshot of the error box was recorded on the base tree before the change, and it still matches.
  • The new tests failed on the base tree before the implementation.
  • The changed and nearby test files (implement step, config declarations, instruments, global dry run, MCP dispatcher, MCP dispatch logs, docs resolver, gh, ci cache, logging bridge, test runner, telemetry): 549 passed before the rebase, and 275 passed after it.
  • No other open pull request changes a file of this one.

Notes for the review:

  • A dry run now shows a usage error in the error box of Typer, the same as a live run. Before, the dry-run branch printed Click's plain form and stopped the error before the root group.
  • The parser of Click raises BadOptionUsage with no context, and Context.invoke then gives it the context of the parent group. The parse_args hook marks the command path where the parse fails, so devops pr list --limit records pr list. The error keeps its context, so the error box does not change.

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 08:27
@dan-petty
dan-petty merged commit a179fd9 into main Nov 12, 2026
30 checks passed
@dan-petty
dan-petty deleted the feat/4839-usage-error-capture branch November 12, 2026 12:04
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.118.0](v0.117.2...v0.118.0)
(2026-11-12)


### Features

* **ci:** devops ci stops its rows when timeout ends it
([#5031](#5031))
([1fa4e9c](1fa4e9c))
* **roadmap:** keep the stage gate problems as a list with a code
([#5022](#5022))
([5819627](5819627))
* **roadmap:** log one result line for each roadmap job attempt
([#4966](#4966))
([2b6fe3f](2b6fe3f))
* **telemetry:** record each CLI usage error by name and kind
([#4973](#4973))
([a179fd9](a179fd9))


### Bug Fixes

* **ai:** chat loads each persona prompt and challenger gets tools
([#5037](#5037))
([c40b0ad](c40b0ad))
* **ai:** keep the HTTP status of a Claude reply after retries
([#4976](#4976))
([5bf9466](5bf9466))
* **deps:** keep Renovate uv bumps green and groups on Monday
([#4987](#4987))
([b19e153](b19e153))
* **k8s:** raise the limits that 7 d of use shows are too low
([#5030](#5030))
([028c62b](028c62b))
* **roadmap:** a job posts no comment that repeats a recent one
([#4978](#4978))
([fff903a](fff903a))
* **service:** alert when GitHub cannot deliver a webhook
([#5045](#5045))
([2bfbfcb](2bfbfcb))
* **service:** delete the stream route that sends canned verified text
([#5038](#5038))
([e9d51b5](e9d51b5))
* **telemetry:** keep one upstream status series per service
([#4986](#4986))
([3e4ca56](3e4ca56))
* **tests:** remove the runner variable in the test floor
([#4988](#4988))
([093aa61](093aa61))


### Performance Improvements

* **ai:** make the ast graph walk and call search faster
([#5039](#5039))
([3b25cc6](3b25cc6)),
closes [#4662](#4662)
* **ci:** build the devcontainer only on its own inputs
([#4977](#4977))
([c5b15ac](c5b15ac))
* **ci:** test each merge once, on the push to main
([#5043](#5043))
([c6992b1](c6992b1))
* **tests:** remove fixed waste in six slow tests
([#4995](#4995))
([1c7044e](1c7044e))


### Code Refactoring

* **ai:** delete devops ai pipeline and persona leftovers
([#5044](#5044))
([d5fefde](d5fefde)),
closes [#4827](#4827)
* **openspec:** split big capabilities into nested ones
([#4981](#4981))
([dfb09bd](dfb09bd))
* **pr:** devops pr update acts only on a failed check
([#4990](#4990))
([aa4fa1a](aa4fa1a))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/telemetry OpenTelemetry tracing spans, Prometheus metrics, and Jaeger type/feature Type feature: a new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(telemetry): record each CLI usage error by name and kind

1 participant