Class: GitLab::Exporter::Database::BloatCollector

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

Overview

Helper to collect bloat metrics.

Constant Summary

Constants inherited from Base

GitLab::Exporter::Database::Base::POOL_SIZE, GitLab::Exporter::Database::Base::POOL_TIMEOUT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

configure_type_map_for_results, connection_pool, #connection_pool, #initialize, #with_connection_pool

Constructor Details

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

Instance Attribute Details

#logger=(value) ⇒ Object (writeonly)

Sets the attribute logger

Parameters:

  • value

    the value to set the attribute logger to.



6
7
8
# File 'lib/gitlab_exporter/database/bloat.rb', line 6

def logger=(value)
  @logger = value
end

Class Method Details

.query_for(type) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab_exporter/database/bloat.rb', line 23

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



8
9
10
11
12
# File 'lib/gitlab_exporter/database/bloat.rb', line 8

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