Repository: prometheus/client_python (python)

Issue:
Issue with prometheus_multiproc_dir deprecation
Hi !

I noticed an issue with prometheus_multiproc_dir deprecation in the latest 0.10.0 version.
In `mark_process_dead()` the environment variable transition code is not present, which means that if the uppercase version is not set, the function does not work.
https://github.com/prometheus/client_python/pull/624/files#diff-95ab27209a655ee3a508d436368ba4e1d155784c5885e18be09b61c2a5ec03efL155

Since we can call `mark_process_dead()` without going through the `__init__()` methods that set the new environment variable, it would required something like this : https://github.com/prometheus/client_python/pull/624/files#diff-f1ab5b765643c2beafab5bcd9874a839f7ebf080300e1ee0dbdb821755f8e904R56-R58




Pull request description:
mark_process_dead respects old env var
Some users use mark_process_dead without going through any of the
`__init__()` logic which sets the new environment variable.

I chose not to put in the warnings in another place as a user will go
through the deprecation path somewhere already.

Fixes #643 

Patch:
diff --git a/prometheus_client/multiprocess.py b/prometheus_client/multiprocess.py
index d32156c..03e3f4d 100644
--- a/prometheus_client/multiprocess.py
+++ b/prometheus_client/multiprocess.py
@@ -157,7 +157,7 @@ class MultiProcessCollector(object):
 def mark_process_dead(pid, path=None):
     """Do bookkeeping for when one process dies in a multi-process setup."""
     if path is None:
-        path = os.environ.get('PROMETHEUS_MULTIPROC_DIR')
+        path = os.environ.get('PROMETHEUS_MULTIPROC_DIR', os.environ.get('prometheus_multiproc_dir'))
     for f in glob.glob(os.path.join(path, 'gauge_livesum_{0}.db'.format(pid))):
         os.remove(f)
     for f in glob.glob(os.path.join(path, 'gauge_liveall_{0}.db'.format(pid))):


Test patch:
diff --git a/tests/test_multiprocess.py b/tests/test_multiprocess.py
index f1fc06b..96792a3 100644
--- a/tests/test_multiprocess.py
+++ b/tests/test_multiprocess.py
@@ -30,8 +30,8 @@ class TestMultiProcessDeprecation(unittest.TestCase):
         self.tempdir = tempfile.mkdtemp()
 
     def tearDown(self):
-        del os.environ['prometheus_multiproc_dir']
-        del os.environ['PROMETHEUS_MULTIPROC_DIR']
+        os.environ.pop('prometheus_multiproc_dir', None)
+        os.environ.pop('PROMETHEUS_MULTIPROC_DIR', None)
         values.ValueClass = MutexValue
         shutil.rmtree(self.tempdir)
 
@@ -48,6 +48,12 @@ class TestMultiProcessDeprecation(unittest.TestCase):
             assert issubclass(w[-1].category, DeprecationWarning)
             assert "PROMETHEUS_MULTIPROC_DIR" in str(w[-1].message)
 
+    def test_mark_process_dead_respects_lowercase(self):
+        os.environ['prometheus_multiproc_dir'] = self.tempdir
+        # Just test that this does not raise with a lowercase env var. The
+        # logic is tested elsewhere.
+        mark_process_dead(123)
+
 
 class TestMultiProcess(unittest.TestCase):
     def setUp(self):