Only trigger prometheus if configured (#231)

* fix prometheus integration

* fix prometheus integration

* Add also lowercase option

As they seem to support that too: d7c9cd88c7/prometheus_client/multiprocess.py (L166-L167)

* format

---------

Co-authored-by: Stan Triepels <1939656+GDay@users.noreply.github.com>
This commit is contained in:
Paulo Coutinho
2024-10-10 23:09:17 -03:00
committed by GitHub
parent c1e00b09cb
commit c3b49cca25

View File

@@ -1,4 +1,5 @@
# Standard
import os
import signal
import socket
import uuid
@@ -230,8 +231,14 @@ class Sentinel:
% {"name": process.name}
)
else:
if prometheus_multiprocess:
# check if prometheus is proper configurated
prometheus_path = os.getenv(
"PROMETHEUS_MULTIPROC_DIR", os.getenv("prometheus_multiproc_dir")
)
if prometheus_multiprocess and prometheus_path:
prometheus_multiprocess.mark_process_dead(process.pid)
self.pool.remove(process)
self.spawn_worker()
if process.timer.value == 0: