Skip to content

Commit 4abe4ec

Browse files
committed
rename getMultiprocDir as private
1 parent 65a0b4e commit 4abe4ec

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

prometheus_client/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from .metrics_core import Metric
1414
from .registry import Collector, CollectorRegistry, REGISTRY
1515
from .samples import Exemplar, Sample
16-
from .utils import floatToGoString, getMultiprocDir, INF
16+
from .utils import _getMultiprocDir, floatToGoString, INF
1717
from .validation import (
1818
_validate_exemplar, _validate_labelnames, _validate_metric_name,
1919
)
@@ -190,7 +190,7 @@ def labels(self: T, *labelvalues: Any, **labelkwargs: Any) -> T:
190190
return self._metrics[labelvalues]
191191

192192
def remove(self, *labelvalues: Any) -> None:
193-
if getMultiprocDir():
193+
if _getMultiprocDir():
194194
warnings.warn(
195195
"Removal of labels has not been implemented in multi-process mode yet.",
196196
UserWarning)
@@ -208,7 +208,7 @@ def remove(self, *labelvalues: Any) -> None:
208208

209209
def clear(self) -> None:
210210
"""Remove all labelsets from the metric"""
211-
if getMultiprocDir():
211+
if _getMultiprocDir():
212212
warnings.warn(
213213
"Clearing labels has not been implemented in multi-process mode yet",
214214
UserWarning)

prometheus_client/multiprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .metrics_core import Metric
88
from .mmap_dict import MmapedDict
99
from .samples import Sample
10-
from .utils import floatToGoString, getMultiprocDir
10+
from .utils import _getMultiprocDir, floatToGoString
1111

1212
try: # Python3
1313
FileNotFoundError
@@ -21,7 +21,7 @@ class MultiProcessCollector:
2121

2222
def __init__(self, registry, path=None):
2323
if path is None:
24-
path = getMultiprocDir()
24+
path = _getMultiprocDir()
2525
if not path or not os.path.isdir(path):
2626
raise ValueError('env PROMETHEUS_MULTIPROC_DIR is not set or not a directory')
2727
self._path = path
@@ -160,7 +160,7 @@ def collect(self):
160160
def mark_process_dead(pid, path=None):
161161
"""Do bookkeeping for when one process dies in a multi-process setup."""
162162
if path is None:
163-
path = getMultiprocDir()
163+
path = _getMultiprocDir()
164164
for mode in _LIVE_GAUGE_MULTIPROCESS_MODES:
165165
for f in glob.glob(os.path.join(path, f'gauge_{mode}_{pid}.db')):
166166
os.remove(f)

prometheus_client/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def floatToGoString(d):
2727

2828

2929

30-
def getMultiprocDir() -> str:
30+
def _getMultiprocDir() -> str:
3131
if 'prometheus_multiproc_dir' in os.environ and 'PROMETHEUS_MULTIPROC_DIR' not in os.environ:
3232
os.environ['PROMETHEUS_MULTIPROC_DIR'] = os.environ['prometheus_multiproc_dir']
3333
warnings.warn("prometheus_multiproc_dir variable has been deprecated in favor of the upper case naming PROMETHEUS_MULTIPROC_DIR", DeprecationWarning)

prometheus_client/values.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from threading import Lock
33

44
from .mmap_dict import mmap_key, MmapedDict
5-
from .utils import getMultiprocDir
5+
from .utils import _getMultiprocDir
66

77

88
class MutexValue:
@@ -58,7 +58,7 @@ class MmapedValue:
5858
_multiprocess = True
5959

6060
def __init__(self, typ, metric_name, name, labelnames, labelvalues, help_text, multiprocess_mode='', multiprocess_dir='', **kwargs):
61-
self._params = typ, metric_name, name, labelnames, labelvalues, help_text, multiprocess_mode, multiprocess_dir or getMultiprocDir()
61+
self._params = typ, metric_name, name, labelnames, labelvalues, help_text, multiprocess_mode, multiprocess_dir or _getMultiprocDir()
6262
with lock:
6363
self.__check_for_pid_change()
6464
self.__reset()
@@ -127,7 +127,7 @@ def get_value_class():
127127
# This needs to be chosen before the first metric is constructed,
128128
# and as that may be in some arbitrary library the user/admin has
129129
# no control over we use an environment variable.
130-
if getMultiprocDir():
130+
if _getMultiprocDir():
131131
return MultiProcessValue()
132132
else:
133133
return MutexValue

0 commit comments

Comments
 (0)