Summary
CLI query commands (search, definition, references, callers, callees, etc. — entry points around QueryCommandRunner.cs:83-165) emit human-readable console output but don't write structured (JSON) event lines correlating input parameters (lang, limit, path filters) with elapsed time and result count. Only index captures ElapsedMs in its result envelope. Operators running cdidx in CI or as part of a larger pipeline have no machine-readable trace of query performance — slow queries can only be debugged interactively.
Where
Suggested approach
(1) Wrap every query command with a structured-log envelope written to stderr (or to a configured trace sink): tool name, parameters (sanitised — cross-link C548), elapsed_ms, result_count, error (if any). One JSON line per invocation. (2) Make this opt-in via --trace=stderr|file|none (default none for CLI to keep output clean) so existing scripts aren't surprised. (3) When --trace=file is set, write to a per-day rotating log file under the same directory as GlobalToolLog (cross-link the just-filed C544). (4) For --json output, optionally include a _trace field with the structured envelope so machine consumers get the data without a separate sink. (5) Add regression tests: each query command writes one structured trace line, fields match the documented schema, redaction works (cross-link C548). (6) Cross-link with #1471, #1817, and the just-filed C546 (MCP tool telemetry) / C549 (correlation ID).
Summary
CLI query commands (search, definition, references, callers, callees, etc. — entry points around QueryCommandRunner.cs:83-165) emit human-readable console output but don't write structured (JSON) event lines correlating input parameters (lang, limit, path filters) with elapsed time and result count. Only
indexcapturesElapsedMsin its result envelope. Operators running cdidx in CI or as part of a larger pipeline have no machine-readable trace of query performance — slow queries can only be debugged interactively.Where
src/CodeIndex/Cli/QueryCommandRunner.cs:83-165(search entry — pattern repeats across other query commands)Suggested approach
(1) Wrap every query command with a structured-log envelope written to stderr (or to a configured trace sink): tool name, parameters (sanitised — cross-link C548), elapsed_ms, result_count, error (if any). One JSON line per invocation. (2) Make this opt-in via
--trace=stderr|file|none(defaultnonefor CLI to keep output clean) so existing scripts aren't surprised. (3) When--trace=fileis set, write to a per-day rotating log file under the same directory as GlobalToolLog (cross-link the just-filed C544). (4) For--jsonoutput, optionally include a_tracefield with the structured envelope so machine consumers get the data without a separate sink. (5) Add regression tests: each query command writes one structured trace line, fields match the documented schema, redaction works (cross-link C548). (6) Cross-link with #1471, #1817, and the just-filed C546 (MCP tool telemetry) / C549 (correlation ID).