feat: add infrastructure status to health endpoint

This commit is contained in:
Mondo Diaz
2026-02-04 09:54:45 -06:00
parent 08291a2f56
commit 9a1d578525
2 changed files with 28 additions and 6 deletions

View File

@@ -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 ---