Class: Splash::Commands::CmdNotifier
- Inherits:
-
Object
- Object
- Splash::Commands::CmdNotifier
- 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
-
#initialize(options = {}) ⇒ CmdNotifier
constructor
A new instance of CmdNotifier.
-
#notify ⇒ Bool
send metrics to Prometheus PushGateway.
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(={}) @config = get_config @url = @config.prometheus_pushgateway_url @name = "cmd_#{[:name].to_s}" @exitcode = [:exitcode] @time = [:time] end |
Instance Method Details
#notify ⇒ Bool
send metrics to Prometheus PushGateway
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 |