Module: Appsignal::CheckIn
- Defined in:
- lib/appsignal/check_in.rb,
lib/appsignal/check_in/cron.rb,
lib/appsignal/check_in/event.rb,
lib/appsignal/check_in/scheduler.rb,
sig/appsignal.rbs
Class Method Summary collapse
-
.cron(identifier) ⇒ void
Track cron check-ins.
-
.heartbeat(identifier, continuous: false) ⇒ void
Track heartbeat check-ins.
Class Method Details
.cron(identifier) ⇒ void
This method returns an undefined value.
Track cron check-ins.
Track the execution of scheduled processes by sending a cron check-in.
To track the duration of a piece of code, pass a block to cron to report both when the process starts, and when it finishes.
If an exception is raised within the block, the finish event will not be reported, triggering a notification about the missing cron check-in. The exception will bubble outside of the cron check-in block.
@param identifier — identifier of the cron check-in to report.
@return — returns the block value.
Send a cron check-in
Appsignal::CheckIn.cron("send_invoices")
Send a cron check-in with duration
Appsignal::CheckIn.cron("send_invoices") do
# your code
end
@see https://docs.appsignal.com/check-ins/cron
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/appsignal/check_in.rb', line 46 def cron(identifier) cron = Appsignal::CheckIn::Cron.new(:identifier => identifier) output = nil if block_given? cron.start output = yield end cron.finish output end |
.heartbeat(identifier, continuous: false) ⇒ void
This method returns an undefined value.
Track heartbeat check-ins.
Track the execution of long-lived processes by sending a heartbeat check-in.
@param identifier — identifier of the heartbeat check-in to report.
@param continuous — whether the heartbeats should be sent continuously during the lifetime of the process. Defaults to false.
Send a heartbeat check-in
Appsignal::CheckIn.heartbeat("main_loop")
@see https://docs.appsignal.com/check-ins/heartbeat
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/appsignal/check_in.rb', line 74 def heartbeat(identifier, continuous: false) if continuous continuous_heartbeats << Thread.new do loop do heartbeat(identifier) sleep HEARTBEAT_CONTINUOUS_INTERVAL_SECONDS end end return end event = Event.heartbeat(:identifier => identifier) scheduler.schedule(event) end |