31 lines
735 B
Ruby
31 lines
735 B
Ruby
class Metrics::EstimateDbRowsReporter < Metrics::Reporter
|
|
def initialize
|
|
log_writes!
|
|
super
|
|
end
|
|
|
|
def report
|
|
extra_tables = [
|
|
"http_log_entries",
|
|
"http_log_entry_headers",
|
|
"versions",
|
|
"delayed_jobs",
|
|
"blob_entries_p",
|
|
]
|
|
extra_tables_sql = extra_tables.map { |t| "'#{t}'" }.join(",")
|
|
row_estimates = ReduxApplicationRecord.connection.exec_query(
|
|
[
|
|
"SELECT relname, n_live_tup",
|
|
"FROM pg_stat_all_tables",
|
|
"WHERE relname IN (#{extra_tables_sql})",
|
|
"OR relname like 'domain_%'",
|
|
"OR relname like 'blob_entries_p_%'",
|
|
].join(" ")
|
|
).rows.to_h
|
|
|
|
write_point(
|
|
"estimate_db_rows", fields: row_estimates,
|
|
)
|
|
end
|
|
end
|