From 6f7014daf5d5bbc64f46ceaee157faaa1803c5bc Mon Sep 17 00:00:00 2001 From: Andrew Gershman Date: Fri, 15 Dec 2023 10:41:33 -0500 Subject: [PATCH] Allow set of prometheus collector addr as env var --- CONTRIBUTORS.txt | 3 ++- src/celery_prometheus/prometheus_bootstep.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index f02ecf1..bc0aba7 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -1,2 +1,3 @@ Guillaume Gauvrit -Michael Vieira \ No newline at end of file +Michael Vieira +Andrew Gershman \ No newline at end of file diff --git a/src/celery_prometheus/prometheus_bootstep.py b/src/celery_prometheus/prometheus_bootstep.py index 699e521..c729edc 100644 --- a/src/celery_prometheus/prometheus_bootstep.py +++ b/src/celery_prometheus/prometheus_bootstep.py @@ -1,5 +1,6 @@ """Helper for celery.""" import logging +import os from argparse import ArgumentParser from typing import Any, Mapping, Optional, cast @@ -26,7 +27,11 @@ def add_prometheus_option(app: Celery) -> None: if celery_version.major < 5: def add_preload_arguments(parser: ArgumentParser) -> None: - parser.add_argument("--prometheus-collector-addr", default=None, help=help) + parser.add_argument( + "--prometheus-collector-addr", + default=os.getenv("CELERY_PROMETHEUS_COLLECTOR_ADDR"), + help=help, + ) app.user_options["preload"].add(add_preload_arguments) else: