Class: GitLab::Exporter::Database::BloatProber

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

Overview

Prober class to gather bloat metrics

Constant Summary collapse

METRIC_KEYS =
%w[bloat_ratio bloat_size extra_size real_size].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metrics: PrometheusMetrics.new, logger: nil, **opts) ⇒ BloatProber

Returns a new instance of BloatProber.



42
43
44
45
46
47
48
49
# File 'lib/gitlab_exporter/database/bloat.rb', line 42

def initialize(metrics: PrometheusMetrics.new,
               logger: nil,
               **opts)
  @metrics = metrics
  @collector = opts[:collector] || BloatCollector.new(**opts)
  @collector.logger = logger
  @bloat_types = opts[:bloat_types] || %i[btree table]
end

Instance Attribute Details

#bloat_typesObject (readonly)

Returns the value of attribute bloat_types.



40
41
42
# File 'lib/gitlab_exporter/database/bloat.rb', line 40

def bloat_types
  @bloat_types
end

#collectorObject (readonly)

Returns the value of attribute collector.



40
41
42
# File 'lib/gitlab_exporter/database/bloat.rb', line 40

def collector
  @collector
end

#metricsObject (readonly)

Returns the value of attribute metrics.



40
41
42
# File 'lib/gitlab_exporter/database/bloat.rb', line 40

def metrics
  @metrics
end

Instance Method Details

#probe_dbObject



51
52
53
54
55
# File 'lib/gitlab_exporter/database/bloat.rb', line 51

def probe_db
  bloat_types.each do |type|
    probe_for_type(type)
  end
end

#write_to(target) ⇒ Object



57
58
59
# File 'lib/gitlab_exporter/database/bloat.rb', line 57

def write_to(target)
  target.write(metrics.to_s)
end