debian-mirror-gitlab/lib/gitlab/database/partitioning/partition_monitoring.rb

32 lines
1.1 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
module Gitlab
module Database
module Partitioning
class PartitionMonitoring
2021-12-11 22:18:48 +05:30
def report_metrics_for_model(model)
strategy = model.partitioning_strategy
2020-11-24 15:15:51 +05:30
2021-12-11 22:18:48 +05:30
gauge_present.set({ table: model.table_name }, strategy.current_partitions.size)
gauge_missing.set({ table: model.table_name }, strategy.missing_partitions.size)
gauge_extra.set({ table: model.table_name }, strategy.extra_partitions.size)
2020-11-24 15:15:51 +05:30
end
private
def gauge_present
@gauge_present ||= Gitlab::Metrics.gauge(:db_partitions_present, 'Number of database partitions present')
end
def gauge_missing
@gauge_missing ||= Gitlab::Metrics.gauge(:db_partitions_missing, 'Number of database partitions currently expected, but not present')
end
2021-10-27 15:23:28 +05:30
def gauge_extra
@gauge_extra ||= Gitlab::Metrics.gauge(:db_partitions_extra, 'Number of database partitions currently attached to tables, but outside of their retention window and scheduled to be dropped')
end
2020-11-24 15:15:51 +05:30
end
end
end
end