Skip to content

fix(observability): route RAG pipeline errors through console.error so Sentry sees them #3894

Description

@JSONbored

Context

src/selfhost/sentry.ts documents this codebase's console-forwarding convention: console.error is forwarded to Sentry by default; console.log needs an explicit level:"error"/"fatal" field to be forwarded at all.

Four catch blocks in src/review/rag.ts (embedTexts ~line 303 rag_embed_error, upsertChunks ~line 335 rag_upsert_error, deleteChunksForPaths ~line 363 rag_delete_error, readChunkTexts ~line 568 rag_chunk_read_error) use bare console.log(JSON.stringify({...})) with no level field — invisible to Sentry. Two more in src/review/rag-index.ts (rag_index_repo_error ~line 318, rag_reindex_paths_error ~line 381) have the same problem. The sibling retrieveContextWithMetrics catch in the same rag.ts file was already fixed to console.error(JSON.stringify({level:"error",...})) with a comment noting the prior invisible-to-Sentry bug — that fix was never extended to the other call sites in the same module.

None of these paths increment a Prometheus counter either: gittensory_qdrant_errors_total only fires inside the Qdrant adapter itself, and embedTexts returns null before ever reaching a counted call — so an embedding-provider outage is invisible to GittensoryQdrantErrorRateHigh entirely.

Requirements

  • Change the six cited call sites to console.error with an explicit level: "error" field, mirroring the already-fixed sibling in the same file.
  • Add a Prometheus counter (e.g. gittensory_rag_pipeline_errors_total{op="embed|upsert|delete|chunk_read|index|reindex"}) distinct from gittensory_qdrant_errors_total, so an embedding-provider outage is alertable independent of the vector store's own health.

Acceptance criteria

  • All six error paths reach Sentry the same way the already-fixed sibling does.
  • A new counter exists and increments on each of these failure classes; tests cover it.

Parent: #1667

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.

Projects

Status
Done

Relationships

None yet

Development

No branches or pull requests

Issue actions