Class: GitLab::Monitor::Database::BloatCollector

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab_monitor/database/bloat.rb

Overview

Helper to collect bloat metrics.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connection_pool, #connection_pool, #initialize, #with_connection_pool

Constructor Details

This class inherits a constructor from GitLab::Monitor::Database::Base

Class Method Details

.query_for(type) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab_monitor/database/bloat.rb', line 21

def query_for(type)
  @queries ||= {}

  return @queries[type] if @queries[type]

  file = File.join(__dir__, "bloat_#{type}.sql")
  fail "Unknown bloat query file: #{file}" unless File.exist?(file)

  @queries[type] = File.read(file)
end

Instance Method Details

#run(type = :btree) ⇒ Object



6
7
8
9
10
# File 'lib/gitlab_monitor/database/bloat.rb', line 6

def run(type = :btree)
  execute(self.class.query_for(type)).each_with_object({}) do |row, h|
    h[row["object_name"]] = row
  end
end