Fixed incorrect parsing behavior for float-type metrics

This commit is contained in:
Dana Van Aken 2019-10-01 01:21:46 -04:00
parent d1c13de42f
commit 863d6619ba
5 changed files with 11 additions and 10 deletions

View File

@ -246,7 +246,7 @@
"dbms": 2,
"name": "pg_stat_database.blk_read_time",
"summary": "\"Time spent reading data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},
@ -312,7 +312,7 @@
"dbms": 2,
"name": "pg_stat_database.blk_write_time",
"summary": "\"Time spent writing data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},

View File

@ -246,7 +246,7 @@
"dbms": 3,
"name": "pg_stat_database.blk_read_time",
"summary": "\"Time spent reading data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},
@ -312,7 +312,7 @@
"dbms": 3,
"name": "pg_stat_database.blk_write_time",
"summary": "\"Time spent writing data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},

View File

@ -323,7 +323,7 @@
"dbms": 4,
"name": "pg_stat_database.blk_read_time",
"summary": "\"Time spent reading data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},
@ -389,7 +389,7 @@
"dbms": 4,
"name": "pg_stat_database.blk_write_time",
"summary": "\"Time spent writing data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},

View File

@ -323,7 +323,7 @@
"dbms": 1,
"name": "pg_stat_database.blk_read_time",
"summary": "\"Time spent reading data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},
@ -389,7 +389,7 @@
"dbms": 1,
"name": "pg_stat_database.blk_write_time",
"summary": "\"Time spent writing data file blocks by backends in this database, in milliseconds\"",
"vartype": 2,
"vartype": 3,
"metric_type": 1,
"scope": "database"
},

View File

@ -291,7 +291,8 @@ class BaseParser(object, metaclass=ABCMeta):
valid_metrics[name] = values[0]
elif metric.metric_type == MetricType.COUNTER or \
metric.metric_type == MetricType.STATISTICS:
values = [int(v) for v in values if v is not None]
conv_fn = int if metric.vartype == VarType.INTEGER else float
values = [conv_fn(v) for v in values if v is not None]
if len(values) == 0:
valid_metrics[name] = 0
else:
@ -359,7 +360,7 @@ class BaseParser(object, metaclass=ABCMeta):
return int(round(int_value))
def format_real(self, real_value, metadata):
return float(real_value)
return round(float(real_value), 3)
def format_string(self, string_value, metadata):
return string_value