
Chris CoutinhoandClaude
a667d7c59c
feat: Add metrics instrumentation for queue, health, and database operations
Implement Prometheus metrics to populate empty Grafana dashboard panels.
## Phase 1: Queue Size Metrics ✅
**File**: `processor.py`
- Track vector sync queue depth in real-time
- Update metric after receiving and processing each document
- Update metric during timeout (empty queue)
- Enables: "Processing Queue Depth" panel
## Phase 2: Health Check Metrics ✅
**File**: `app.py`
- Add Nextcloud connectivity check with timing
- Add Qdrant health check with timing
- Record dependency health status (up/down)
- Record health check duration
- Enables: 4 health status panels + health check duration panel
## Phase 3: Database Operation Metrics (Partial) ⏳
**File**: `storage.py`
- Instrument `store_refresh_token()` method
- Track SQLite INSERT operation timing and success/error status
- Enables: Partial data for database operation latency panel
## Metrics Now Exposed
### Queue Metrics:
- `mcp_vector_sync_queue_size` - Real-time queue depth
### Health Metrics:
- `mcp_dependency_health{dependency="nextcloud"}` - UP/DOWN status
- `mcp_dependency_health{dependency="qdrant"}` - UP/DOWN status
- `mcp_dependency_check_duration_seconds{dependency}` - Health check latency
### Database Metrics:
- `mcp_db_operations_total{db="sqlite",operation="insert"}` - Operation count
- `mcp_db_operation_duration_seconds{db="sqlite",operation="insert"}` - Operation latency
## Dashboard Impact
**Panels Now Populated** (7/34 panels):
- ✅ Processing Queue Depth
- ✅ Nextcloud Health
- ✅ Qdrant Health
- ✅ Health Check Duration
- ✅ Database Operation Latency (partial)
- ✅ Vector sync panels (already working from PR #292)
**Panels Still Empty** (remaining work):
- ⏳ OAuth panels (4): Token validations, exchanges, cache hit rate, refresh ops
- ⏳ MCP tool panels (3): Call volume, error rates, execution duration
- ⏳ Database panel: Needs more SQLite operations instrumented (~29 remaining)
## Testing
Verified metric definitions exist and will be recorded on next deployment.
## Next Steps
Phase 4: OAuth token metrics (unified_verifier.py, context_helper.py, storage.py)
Phase 5: MCP tool metrics (all server/*.py files with @mcp.tool())
Phase 3 completion: Remaining 29 database operations in storage.py
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 16:14:38 +01:00
..
2025-11-13 16:14:38 +01:00
2025-11-11 20:35:08 +01:00
2025-10-18 22:02:19 +02:00
2025-11-05 15:19:55 +01:00
2025-11-12 02:46:30 +01:00
2025-11-09 05:53:53 +01:00
2025-11-13 11:49:20 +01:00
2025-11-13 11:49:20 +01:00
2025-10-25 19:52:45 +02:00
2025-11-13 16:14:38 +01:00
2025-05-04 23:24:55 +02:00
2025-11-13 16:14:38 +01:00
2025-11-11 20:35:08 +01:00
2025-11-11 23:19:37 +01:00
2025-11-05 21:44:04 +01:00