Class: GitLab::Exporter::Database::CiBuildsProber

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

Overview

The prober which is called when gathering metrics

Instance Method Summary collapse

Constructor Details

#initialize(metrics: PrometheusMetrics.new, **opts) ⇒ CiBuildsProber

Returns a new instance of CiBuildsProber.



297
298
299
300
# File 'lib/gitlab_exporter/database/ci_builds.rb', line 297

def initialize(metrics: PrometheusMetrics.new, **opts)
  @metrics = metrics
  @collector = CiBuildsCollector.new(**opts)
end

Instance Method Details

#probe_dbObject



302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/gitlab_exporter/database/ci_builds.rb', line 302

def probe_db
  @results = @collector.run

  ci_builds_metrics(@results[:created_builds], "ci_created_builds") if @results[:created_builds]
  ci_builds_metrics(@results[:pending_builds], "ci_pending_builds")
  ci_stale_builds_metrics
  metrics_per_runner
  unarchived_traces_metrics

  self
rescue PG::ConnectionBad
  self
end

#write_to(target) ⇒ Object



316
317
318
# File 'lib/gitlab_exporter/database/ci_builds.rb', line 316

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