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
Defined Under Namespace
Classes: Cron, Event, Scheduler
Constant Summary collapse
- HEARTBEAT_CONTINUOUS_INTERVAL_SECONDS =
30
Class Method Summary collapse
- .continuous_heartbeats ⇒ Object private
-
.cron(identifier) { ... } ⇒ void
Track cron check-ins.
-
.heartbeat(identifier, continuous: false) { ... } ⇒ void
Track heartbeat check-ins.
- .kill_continuous_heartbeats ⇒ Object private
- .scheduler ⇒ Object private
- .stop ⇒ Object private
- .transmitter ⇒ Object private
Class Method Details
.continuous_heartbeats ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/appsignal/check_in.rb', line 8 def continuous_heartbeats @continuous_heartbeats ||= [] end |
.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.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/appsignal/check_in.rb', line 41 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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/appsignal/check_in.rb', line 69 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 |
.kill_continuous_heartbeats ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/appsignal/check_in.rb', line 13 def kill_continuous_heartbeats continuous_heartbeats.each(&:kill) end |
.scheduler ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
93 94 95 |
# File 'lib/appsignal/check_in.rb', line 93 def scheduler @scheduler ||= Scheduler.new end |
.stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 |
# File 'lib/appsignal/check_in.rb', line 98 def stop scheduler&.stop end |
.transmitter ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 89 90 |
# File 'lib/appsignal/check_in.rb', line 86 def transmitter @transmitter ||= Transmitter.new( "#{Appsignal.config[:logging_endpoint]}/check_ins/json" ) end |