Skip to content

Commit d3d9911

Browse files
committed
worker: metrics server startup if correct env var set
see PR 85 for context. Also removed double guard of same setting: worker_settings.metrics.enabled
1 parent 468022b commit d3d9911

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

packages/divbase-api/src/divbase_api/worker/metrics.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ def start_metrics_server(port=8101):
321321
For k8s deployment, concurrency must be set to 1 (1 worker process per pod). Scaling will be handled by increasing the number of pods.
322322
Example with concurrency=1: 1 worker process, 1 collection thread, 1 HTTP server.
323323
"""
324-
if not worker_settings.metrics.enabled:
325-
logger.info("Metrics collection disabled via ENABLE_WORKER_METRICS environment variable")
326-
return
327324
global _metrics_server_started
328325

329326
pid = os.getpid()

packages/divbase-api/src/divbase_api/worker/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ def init_worker_metrics(**kwargs):
9999
Start the Prometheus metrics server for the Celery worker. This signal is triggered once per forked worker process.
100100
With celery prefork concurrency=1, only one worker process will start the metrics server.
101101
"""
102-
if worker_settings.metrics.enabled_per_task:
103-
logger.info("Starting worker metrics server on port 8101 (ENABLE_WORKER_METRICS_PER_TASK is set to '1').")
102+
if worker_settings.metrics.enabled:
103+
logger.info("Starting worker metrics server on port 8101.")
104104
start_metrics_server(port=8101)
105105
else:
106-
logger.info("Worker metrics collection disabled (ENABLE_WORKER_METRICS_PER_TASK not set to '1').")
106+
logger.info("Worker metrics collection disabled (ENABLE_WORKER_METRICS not set to '1').")
107107

108108

109109
def dynamic_router(name, args, kwargs, options, task=None, **kw):

0 commit comments

Comments
 (0)