7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/jobtick/monitor.rb', line 7
def self.run(key)
config = JobTick.config
return yield unless config.enabled && !config.api_key.nil?
client = JobTick.client
client.ping(key, status: :started)
started = Process.clock_gettime(MONOTONIC)
result = yield
duration = Process.clock_gettime(MONOTONIC) - started
client.ping(key, status: :completed, duration: duration)
result
rescue StandardError => e
JobTick.client.ping(key, status: :failed, message: e.message)
raise
end
|