Class: Splash::Transfers::TxNotifier

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

Constant Summary collapse

@@registry =
Prometheus::Client::Registry::new
@@metric_nbfiles =
Prometheus::Client::Gauge.new(:txnbfiles, docstring: 'SPLASH metric transfer number of files')
@@metric_nbfiles_failed =
Prometheus::Client::Gauge.new(:txnbfilesfailed, docstring: 'SPLASH metric transfer number of failed files')
@@metric_time =
Prometheus::Client::Gauge.new(:txtime, docstring: 'SPLASH metric transfer execution time')

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TxNotifier

Returns a new instance of TxNotifier.



24
25
26
27
28
29
30
31
# File 'lib/splash/transfers.rb', line 24

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

Instance Method Details

#notifyBool

send metrics to Prometheus PushGateway

Returns:

  • (Bool)


35
36
37
38
39
40
41
42
43
44
# File 'lib/splash/transfers.rb', line 35

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