feat: add router health metrics to node_cache and node-guardian

- Add migration 042_node_cache_router_metrics.sql
- Node guardian now collects router health and sends in heartbeat
- City-service uses cached router_healthy from node_cache
- This allows NODE2 router status to be displayed correctly
This commit is contained in:
Apple
2025-12-01 08:03:46 -08:00
parent 9b9a72ffbd
commit a818f2ac2f
4 changed files with 108 additions and 5 deletions

View File

@@ -255,6 +255,20 @@ class NodeGuardian:
except Exception as e:
logger.warning(f"Swapper metrics collection failed: {e}")
# Collect Router Metrics using node-specific URL
metrics["router_healthy"] = False
metrics["router_version"] = None
try:
r = await self.client.get(f"{self.router_url}/health", timeout=3.0)
if r.status_code == 200:
data = r.json()
status = data.get("status", "").lower()
metrics["router_healthy"] = status in ("healthy", "ok")
metrics["router_version"] = data.get("version")
logger.debug(f"🔀 Router metrics: healthy={metrics['router_healthy']}, version={metrics['router_version']}")
except Exception as e:
logger.debug(f"Router health check failed: {e}")
return metrics