Skip to content

Commit 1189e93

Browse files
committedApr 3, 2022
Prefer uppercase PROMETHEUS_MULTIPROC_DIR
1 parent a1f7e78 commit 1189e93

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed
 

‎Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ COPY alembic.ini alembic.ini
2020

2121
EXPOSE 2017
2222

23-
ENV prometheus_multiproc_dir /tmp/routemaster/prometheus
23+
ENV PROMETHEUS_MULTIPROC_DIR /tmp/routemaster/prometheus
2424

2525
CMD ["routemaster", "--config-file=config.yaml", "serve"]

‎plugins/routemaster-prometheus/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Usage, in your Routemaster configuration file:
1313
This package is based on the official Python Promeutheus bindings in
1414
[`prometheus_client`](https://pypi.org/project/prometheus_client/). In order
1515
for that package to operate in a multithreaded program such as Routemaster,
16-
the environment variable `prometheus_multiproc_dir` must be set to a writeable
16+
the environment variable `PROMETHEUS_MULTIPROC_DIR` must be set to a writeable
1717
directory for temporary files. It does not need to be backed up as nothing
1818
is persisted between application launches.
1919

‎plugins/routemaster-prometheus/routemaster_prometheus/__init__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ def __init__(
6262
path='/metrics',
6363
):
6464
self.path = path
65-
metrics_path = os.environ.get('prometheus_multiproc_dir')
65+
# Lower case spelling prometheus_multiproc_dir is deprecated but still
66+
# supported by prometheus_client.
67+
metrics_path = (
68+
os.environ.get('PROMETHEUS_MULTIPROC_DIR') or
69+
os.environ.get('prometheus_multiproc_dir')
70+
)
6671

6772
if not metrics_path:
6873
raise ValueError(
6974
"PrometheusLogger requires the environment variable "
70-
"`prometheus_multiproc_dir` to be set to a writeable "
75+
"`PROMETHEUS_MULTIPROC_DIR` to be set to a writeable "
7176
"directory.",
7277
)
7378

‎plugins/tests/test_logging_plugins.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def root():
132132

133133

134134
def test_prometheus_logger_wipes_directory_on_startup(app):
135-
tmp = pathlib.Path(os.environ['prometheus_multiproc_dir'])
135+
tmp = pathlib.Path(os.environ['PROMETHEUS_MULTIPROC_DIR'])
136136
tmp.mkdir(parents=True, exist_ok=True)
137137

138138
filepath = tmp / 'foo.txt'
@@ -181,10 +181,10 @@ def test_prometheus_logger_ignores_metrics_path(routemaster_serve_subprocess):
181181

182182

183183
def test_prometheus_logger_validates_metrics_path(app):
184-
orig = os.environ['prometheus_multiproc_dir']
185-
os.environ['prometheus_multiproc_dir'] = ''
184+
orig = os.environ['PROMETHEUS_MULTIPROC_DIR']
185+
os.environ['PROMETHEUS_MULTIPROC_DIR'] = ''
186186

187187
with pytest.raises(ValueError):
188188
PrometheusLogger(app.config)
189189

190-
os.environ['prometheus_multiproc_dir'] = orig
190+
os.environ['PROMETHEUS_MULTIPROC_DIR'] = orig

‎setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ extend_skip =
4646
[tool:pytest]
4747
python_paths=test_data/plugins/
4848
env =
49-
prometheus_multiproc_dir=/tmp/routemaster-tests/prometheus
49+
PROMETHEUS_MULTIPROC_DIR=/tmp/routemaster-tests/prometheus

‎tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ passenv=
1616
PG_USER
1717
PG_PASS
1818
setenv =
19-
prometheus_multiproc_dir={envtmpdir}
19+
PROMETHEUS_MULTIPROC_DIR={envtmpdir}
2020
commands =
2121
mkdir -p build/results
2222
mkdir -p build/artifacts

0 commit comments

Comments
 (0)
Please sign in to comment.