Module: NeetoMonitorRuby::MonitorUtils::ClassMethods

Defined in:
lib/neeto_monitor_ruby/monitor_utils.rb

Instance Method Summary collapse

Instance Method Details

#job(monitor_key, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/neeto_monitor_ruby/monitor_utils.rb', line 22

def job(monitor_key, &block)
  monitor = Monitor.new(monitor_key)
  series = monitor.generate_stamp
  monitor.job_ping(state: JOB_STATES[:run], series:)

  block.call
  monitor.job_ping(state: JOB_STATES[:complete], series:)
rescue StandardError => exception
  monitor.job_ping(state: JOB_STATES[:fail], message: exception.message, series:)
  raise exception
end