From 170561b32ac93e1932faabc5fd3e715e6e39951b Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Wed, 4 Feb 2026 09:54:45 -0600 Subject: [PATCH] feat: add infrastructure status to health endpoint --- backend/app/routes.py | 32 ++++++++++++++++++++++++++------ backend/app/schemas.py | 2 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/backend/app/routes.py b/backend/app/routes.py index 17ff3c8..5d6613f 100644 --- a/backend/app/routes.py +++ b/backend/app/routes.py @@ -421,7 +421,8 @@ def _log_audit( # Health check @router.get("/health", response_model=HealthResponse) -def health_check( +async def health_check( + request: Request, db: Session = Depends(get_db), storage: S3Storage = Depends(get_storage), ): @@ -449,11 +450,30 @@ def health_check( overall_status = "ok" if (storage_healthy and database_healthy) else "degraded" - return HealthResponse( - status=overall_status, - storage_healthy=storage_healthy, - database_healthy=database_healthy, - ) + # Build response with optional infrastructure status + response_data = { + "status": overall_status, + "storage_healthy": storage_healthy, + "database_healthy": database_healthy, + } + + # Add HTTP pool status if available + if hasattr(request.app.state, 'http_client'): + http_client = request.app.state.http_client + response_data["http_pool"] = { + "pool_size": http_client.pool_size, + "worker_threads": http_client.executor_max, + } + + # Add cache status if available + if hasattr(request.app.state, 'cache'): + cache = request.app.state.cache + response_data["cache"] = { + "enabled": cache.enabled, + "connected": await cache.ping() if cache.enabled else False, + } + + return HealthResponse(**response_data) # --- Authentication Routes --- diff --git a/backend/app/schemas.py b/backend/app/schemas.py index b82f0c1..86427c5 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -493,6 +493,8 @@ class HealthResponse(BaseModel): version: str = "1.0.0" storage_healthy: Optional[bool] = None database_healthy: Optional[bool] = None + http_pool: Optional[Dict[str, Any]] = None + cache: Optional[Dict[str, Any]] = None # Garbage collection schemas