SIENTIAPDE-1174

Update dependencies, modify replica count, and implement metrics tracking

- Updated sientia-dataops-library version from 1.3.5 to 1.3.7 in requirements.txt.
- Changed replicaCount in values.yaml from 5 to 3 and incremented image tag from 0.2.7 to 0.3.1.
- Added Prometheus metrics tracking in gates.py and worker.py, including a new write_metrics method.
- Configured Prometheus service and ServiceMonitor in values.yaml for metrics collection.
This commit is contained in:
vitor-aignosi
2025-08-01 10:00:47 -03:00
parent 6fb28a0050
commit 70f1abe681
8 changed files with 349 additions and 11 deletions

View File

@@ -20,13 +20,20 @@ with workflow.unsafe.imports_passed_through():
)
from sientia_do.notifications.handlers import CoreNotificationHandler as NotificationHandler
from sientia_do.temporal.utils.logger import get_logger
from laborious import metrics
from prometheus_client import start_http_server
POD_ID = os.getenv('POD_ID')
async def main():
host = os.getenv('TEMPORAL_HOST', 'localhost:7233')
logger = get_logger(__name__)
logger.info('Starting Worker...')
logger.info(f'Starting Worker with POD_ID: {POD_ID}')
logger.info("Starting prometheus client...")
start_prometheus_server()
logger.info('Starting Notification Handler...')
@@ -125,5 +132,17 @@ async def main():
# Exit with a non-zero status code to indicate failure to Kubernetes
sys.exit(1)
def start_prometheus_server():
try:
port = int(os.getenv("HTTP_METRICS_PORT", 9090))
start_http_server(port)
print(f"Prometheus server started on port {port}.")
metrics.APP_UP.labels(pod_id=POD_ID).set(1) # Mark app as UP
except Exception as e:
print(f"Failed to start Prometheus server: {e}")
os._exit(1)
if __name__ == '__main__':
asyncio.run(main())