Class: GitLab::Exporter::Prober

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

Overview

A class to combine multiple probers into one

Instance Method Summary collapse

Constructor Details

#initialize(metrics: PrometheusMetrics.new, logger: nil, **prober_opts) ⇒ Prober

Returns a new instance of Prober.



5
6
7
8
9
10
11
# File 'lib/gitlab_exporter/prober.rb', line 5

def initialize(metrics: PrometheusMetrics.new, logger: nil, **prober_opts)
  @prober_opts = prober_opts
  @metrics     = metrics
  @logger      = logger

  resolve_prober_classes
end

Instance Method Details

#probe_allObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab_exporter/prober.rb', line 13

def probe_all
  @prober_opts.each do |_probe_name, params|
    Utils.wrap_in_array(params[:opts]).each do |opts|
      prober = params[:class].new(metrics: @metrics, logger: @logger, **opts)
      params[:methods].each do |meth|
        prober.send(meth)
      end
    end
  end
end

#write_to(target) ⇒ Object



24
25
26
# File 'lib/gitlab_exporter/prober.rb', line 24

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