Class: GitLab::Monitor::Prober

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

Overview

A class to combine multiple probers into one

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Prober.


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

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

  resolve_prober_classes
end

Instance Method Details

#probe_allObject


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

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

#write_to(target) ⇒ Object


23
24
25
# File 'lib/gitlab_monitor/prober.rb', line 23

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