Skip to content

QueryCommandRunner: CLI query commands lack structured logging #1901

Description

@Widthdom

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions