feat: structured debug logging with SQLite query timings (B2_LOG) - #33
Conversation
Full-kernel structured logging behind the tracing facade, opt-in via B2_LOG (a tracing filter directive) or B2_DEBUG, rendered by the CLI as JSON Lines on stderr — one flat object per event, ready for jq/DuckDB/ pandas reporting and plotting. stdout stays pure data. - SQLite query timings come from SQLite itself: sqlite3_trace_v2 + SQLITE_TRACE_PROFILE (rusqlite "trace" feature), installed on every connection in db::open. Each b2::sqlite event carries the SQL template (?N placeholders — no bound note content or embedding blobs), numeric duration_us, and vm_steps/fullscan_steps for diagnosing why a query is slow. Statements at/over B2_SLOW_QUERY_MS (default 100) log at WARN with slow=true. - Every Vault façade op runs in a b2::vault span; the CLI subscriber's span-close events time each op in the adapter, so b2-core stays wall-clock-free (determinism boundary unchanged). - Flow milestones: b2::ingest projection/embed pass summaries and a per-note embed_note span (the slowest step, now plottable), b2::search retrieval counts (BM25/vector pool sizes). - Inert until an adapter installs a subscriber; the core suite stays model-free and deterministic. Integration tests assert the JSONL contract end-to-end (b2-core tests/logging.rs, b2-cli tests/cli.rs). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RPbsFi2ti6gtfWmdEu8Fhg
B2_LOG_FILE=<path> writes the JSONL log there instead of stderr, in append mode so successive runs accumulate into one reportable dataset (every event carries its own timestamp). The file is also the guaranteed-pure capture: stderr can interleave human notices (progress lines, skipped-file lists) with log lines in non---json runs. Setting B2_LOG_FILE alone implies B2_LOG=debug; an unopenable path warns and falls back to stderr. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RPbsFi2ti6gtfWmdEu8Fhg
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThe PR adds opt-in JSONL tracing to the CLI, SQLite statement profiling and slow-query classification to ChangesStructured logging and instrumentation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant Vault
participant SQLite
participant Sink
CLI->>Vault: run JSON reindex or search
Vault->>SQLite: execute profiled statements
SQLite->>Sink: emit structured timing events
Vault->>Sink: emit operation and pipeline spans
Sink->>CLI: write JSONL to stderr or B2_LOG_FILE
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Full-kernel structured logging behind the tracing facade, opt-in via
B2_LOG (a tracing filter directive) or B2_DEBUG, rendered by the CLI as
JSON Lines on stderr — one flat object per event, ready for jq/DuckDB/
pandas reporting and plotting. stdout stays pure data.
SQLITE_TRACE_PROFILE (rusqlite "trace" feature), installed on every
connection in db::open. Each b2::sqlite event carries the SQL template
(?N placeholders — no bound note content or embedding blobs), numeric
duration_us, and vm_steps/fullscan_steps for diagnosing why a query is
slow. Statements at/over B2_SLOW_QUERY_MS (default 100) log at WARN
with slow=true.
span-close events time each op in the adapter, so b2-core stays
wall-clock-free (determinism boundary unchanged).
per-note embed_note span (the slowest step, now plottable), b2::search
retrieval counts (BM25/vector pool sizes).
model-free and deterministic. Integration tests assert the JSONL
contract end-to-end (b2-core tests/logging.rs, b2-cli tests/cli.rs).
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01RPbsFi2ti6gtfWmdEu8Fhg
Summary by CodeRabbit
New Features
B2_LOG_FILE.B2_SLOW_QUERY_MSto configure the slow-query threshold.Documentation