Class: Splash::Commands::CmdNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/splash/commands.rb

Constant Summary collapse

@@registry =
Prometheus::Client::Registry::new
@@metric_exitcode =
Prometheus::Client::Gauge.new(:exitcode, docstring: 'SPLASH metric batch exitcode')
@@metric_time =
Prometheus::Client::Gauge.new(:exectime, docstring: 'SPLASH metric batch execution time')

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CmdNotifier

Returns a new instance of CmdNotifier.



20
21
22
23
24
25
26
# File 'lib/splash/commands.rb', line 20

def initialize(options={})
  @config = get_config
  @url = @config.prometheus_pushgateway_url
  @name = "cmd_#{options[:name].to_s}"
  @exitcode = options[:exitcode]
  @time = options[:time]
end

Instance Method Details

#notifyBool

send metrics to Prometheus PushGateway

Returns:

  • (Bool)


30
31
32
33
34
35
36
37
38
# File 'lib/splash/commands.rb', line 30

def notify
  unless verify_service url: @url then
    return { :case => :service_dependence_missing, :more => "Prometheus Notification not send."}
  end
  @@metric_exitcode.set(@exitcode)
  @@metric_time.set(@time)
  hostname = Socket.gethostname
  return Prometheus::Client::Push.new(@name, hostname, @url).add(@@registry)
end