Class: GitLab::Exporter::Database::RemoteMirrorsProber
- Inherits:
-
Object
- Object
- GitLab::Exporter::Database::RemoteMirrorsProber
- Defined in:
- lib/gitlab_exporter/database/remote_mirrors.rb
Overview
The prober which is called when gathering metrics
Instance Method Summary collapse
-
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ RemoteMirrorsProber
constructor
A new instance of RemoteMirrorsProber.
-
#probe_db ⇒ Object
rubocop:disable Metrics/MethodLength.
- #write_to(target) ⇒ Object
Constructor Details
#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ RemoteMirrorsProber
Returns a new instance of RemoteMirrorsProber.
38 39 40 41 42 43 44 |
# 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 |
Instance Method Details
#probe_db ⇒ Object
rubocop:disable Metrics/MethodLength
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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) ⇒ Object
68 69 70 |
# File 'lib/gitlab_exporter/database/remote_mirrors.rb', line 68 def write_to(target) target.write(@metrics.to_s) end |