]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: add slash to prometheus illegal metric name characters
authorMykola Golub <mgolub@suse.com>
Wed, 29 May 2019 06:38:35 +0000 (07:38 +0100)
committerMykola Golub <mgolub@suse.com>
Thu, 30 May 2019 08:18:31 +0000 (09:18 +0100)
(replace with underscore)

While here, change the sequence of replaces to a single regex, as it
becomes too long.

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/pybind/mgr/prometheus/module.py

index 0e4bb0cdbaede4b07b89952d1ad9d36940c72d93..bbbeb8332a045e83e29a6a73afd6b9b06e9e896a 100644 (file)
@@ -121,8 +121,7 @@ class Metric(object):
 
         def promethize(path):
             ''' replace illegal metric name characters '''
-            result = path.replace('.', '_').replace(
-                '+', '_plus').replace('::', '_').replace(' ', '_')
+            result = re.sub(r'[./\s]|::', '_', path).replace('+', '_plus')
 
             # Hyphens usually turn into underscores, unless they are
             # trailing