diff --git a/prometheus_client/exposition.py b/prometheus_client/exposition.py index 4a799308..4aebec3f 100644 --- a/prometheus_client/exposition.py +++ b/prometheus_client/exposition.py @@ -89,7 +89,14 @@ def generate_latest(registry=REGISTRY): """Returns the metrics from the registry in latest text format as a string.""" def sample_line(line): + if 'timestamp' in line and line['timestamp'] is None: + line['timestamp'] = "00:00" + if 'exemplar' in line and line['exemplar'] is None: + line['exemplar'] = "0" if line.labels: + # change None to something idk? + if 'method' in line.labels and line.labels['method'] is None: + line.labels['method'] = "GET request" labelstr = '{{{0}}}'.format(','.join( ['{0}="{1}"'.format( k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"')) diff --git a/prometheus_client/openmetrics/exposition.py b/prometheus_client/openmetrics/exposition.py index 6d5925ed..f30d0cde 100644 --- a/prometheus_client/openmetrics/exposition.py +++ b/prometheus_client/openmetrics/exposition.py @@ -21,6 +21,8 @@ def generate_latest(registry): output.append('# UNIT {0} {1}\n'.format(mname, metric.unit)) for s in metric.samples: if s.labels: + if 'method' in s.labels and s.labels['method'] is None: + s.labels['method'] = "GET request" labelstr = '{{{0}}}'.format(','.join( ['{0}="{1}"'.format( k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))