Class: GitLab::Monitor::Database::CiBuildsProber

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

Overview

The prober which is called when gathering metrics

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CiBuildsProber.



411
412
413
414
415
416
417
418
419
# File 'lib/gitlab_monitor/database/ci_builds.rb', line 411

def initialize(opts, metrics: PrometheusMetrics.new)
  @metrics = metrics

  collector_opts = { connection_string: opts[:connection_string],
                     allowed_repeated_commands_count: opts[:allowed_repeated_commands_count],
                     created_builds_counting_disabled: opts[:created_builds_counting_disabled],
                     unarchived_traces_offset_minutes: opts[:unarchived_traces_offset_minutes] }
  @collector = CiBuildsCollector.new(collector_opts)
end

Instance Method Details

#probe_dbObject



421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/gitlab_monitor/database/ci_builds.rb', line 421

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
  repeated_commands_metrics
  unarchived_traces_metrics

  self
rescue PG::ConnectionBad
  self
end

#write_to(target) ⇒ Object



436
437
438
# File 'lib/gitlab_monitor/database/ci_builds.rb', line 436

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