feat: add timestamp in health check
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
"""Blueprint for task-related routes."""
|
"""Blueprint for task-related routes."""
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date, timezone
|
||||||
from typing import Dict, Any, Tuple
|
from typing import Dict, Any, Tuple
|
||||||
|
|
||||||
from flask import Blueprint, render_template, request, jsonify, Response
|
from flask import Blueprint, render_template, request, jsonify, Response
|
||||||
@@ -34,13 +34,15 @@ def health_check() -> Response:
|
|||||||
db.session.scalar(text('SELECT 1'))
|
db.session.scalar(text('SELECT 1'))
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'healthy',
|
'status': 'healthy',
|
||||||
'database': 'connected'
|
'database': 'connected',
|
||||||
|
'timestamp': datetime.now(timezone.utc).isoformat()
|
||||||
}), 200
|
}), 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Health check failed: {e}')
|
logger.error(f'Health check failed: {e}')
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'unhealthy',
|
'status': 'unhealthy',
|
||||||
'database': 'disconnected',
|
'database': 'disconnected',
|
||||||
|
'timestamp': datetime.now(timezone.utc).isoformat(),
|
||||||
'error': str(e)
|
'error': str(e)
|
||||||
}), 503
|
}), 503
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user