Skip to content

Commit 868124a

Browse files
Use regular division and round
1 parent ea6b865 commit 868124a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

postgresql_metrics/metrics_gatherer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def get_multixact_members_per_mxid(data_dir, db_connection):
174174

175175
def get_multixact_members_usage_ratio(data_dir, _db_connection):
176176
members = _get_multixact_members(data_dir)
177-
ratio = members // MAX_MULTIXACT_MEMBERS
177+
ratio = round(members / MAX_MULTIXACT_MEMBERS, 2)
178178
percentage_remaining = (1.0 - ratio) * 100
179179
return [metric_multixact_members_remaining_ratio(percentage_remaining)]
180180

@@ -183,7 +183,7 @@ def get_multixact_remaining_ratio(_data_dir, db_connection):
183183
mxid_age = get_max_mxid_age(db_connection)
184184
if not mxid_age:
185185
return []
186-
ratio = mxid_age // WRAPAROUND_LIMIT
186+
ratio = round(mxid_age / WRAPAROUND_LIMIT, 2)
187187
percentage_remaining = (1.0 - ratio) * 100
188188
return [metric_multixact_remaining_ratio(percentage_remaining)]
189189

@@ -192,7 +192,7 @@ def get_xid_remaining_ratio(_data_dir, db_connection):
192192
xid_age = get_max_xid_age(db_connection)
193193
if not xid_age:
194194
return []
195-
ratio = xid_age // WRAPAROUND_LIMIT
195+
ratio = round(xid_age / WRAPAROUND_LIMIT, 2)
196196
percentage_remaining = (1.0 - ratio) * 100
197197
return [metric_xid_remaining_ratio(percentage_remaining)]
198198

0 commit comments

Comments
 (0)