class GitLab::Exporter::Database::TuplesProber

Probes the DB specified by opts for tuple stats, then converts them to metrics

Public Class Methods

new(metrics: PrometheusMetrics.new, **opts) click to toggle source
# File lib/gitlab_exporter/database/tuple_stats.rb, line 28
def initialize(metrics: PrometheusMetrics.new, **opts)
  @metrics   = metrics
  @collector = TupleStatsCollector.new(**opts)
end

Public Instance Methods

probe_db() click to toggle source
# File lib/gitlab_exporter/database/tuple_stats.rb, line 33
def probe_db
  result = @collector.run

  result.each do |table_name, tuple_stats|
    tuple_stats.each do |column_name, value|
      next if value.is_a?(Numeric)

      @metrics.add("gitlab_database_stat_table_#{column_name}",
                   value.to_f,
                   table_name: table_name)
    end
  end

  self
rescue PG::ConnectionBad
  self
end
write_to(target) click to toggle source
# File lib/gitlab_exporter/database/tuple_stats.rb, line 51
def write_to(target)
  target.write(@metrics.to_s)
end