class GitLab::Exporter::Database::RemoteMirrorsProber
The prober which is called when gathering metrics
Public Class Methods
new(metrics: PrometheusMetrics.new, **opts)
click to toggle source
# File lib/gitlab_exporter/database/remote_mirrors.rb, line 38 def initialize(metrics: PrometheusMetrics.new, **opts) @metrics = metrics @collector = RemoteMirrorsCollector.new( connection_string: opts[:connection_string], project_ids: opts[:project_ids] ) end
Public Instance Methods
probe_db()
click to toggle source
# File lib/gitlab_exporter/database/remote_mirrors.rb, line 46 def probe_db # rubocop:disable Metrics/MethodLength results = @collector.run results.to_a.each do |row| @metrics.add( "project_remote_mirror_last_successful_update_time_seconds", row["last_successful_update_at"].to_f, project_id: row["project_id"], url: row["url"] ) @metrics.add( "project_remote_mirror_last_update_time_seconds", row["last_update_at"].to_f, project_id: row["project_id"], url: row["url"] ) end self rescue PG::ConnectionBad self end
write_to(target)
click to toggle source
# File lib/gitlab_exporter/database/remote_mirrors.rb, line 68 def write_to(target) target.write(@metrics.to_s) end