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