Module: Appsignal::CheckIn

Defined in:
lib/appsignal/check_in.rb,
lib/appsignal/check_in/cron.rb,
lib/appsignal/check_in/scheduler.rb

Defined Under Namespace

Classes: Cron, Scheduler

Class Method Summary collapse

Class Method Details

.cron(identifier) { ... } ⇒ void

This method returns an undefined value.

Track cron check-ins.

Track the execution of certain 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.

Examples:

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

Parameters:

  • name (String)

    name of the cron check-in to report.

Yields:

  • the block to monitor.

See Also:

Since:

  • 3.13.0



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/appsignal/check_in.rb', line 30

def cron(identifier)
  cron = Appsignal::CheckIn::Cron.new(:identifier => identifier)
  output = nil

  if block_given?
    cron.start
    output = yield
  end

  cron.finish
  output
end

.schedulerObject

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.



51
52
53
# File 'lib/appsignal/check_in.rb', line 51

def scheduler
  @scheduler ||= Scheduler.new
end

.stopObject

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.



56
57
58
# File 'lib/appsignal/check_in.rb', line 56

def stop
  scheduler&.stop
end

.transmitterObject

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.



44
45
46
47
48
# File 'lib/appsignal/check_in.rb', line 44

def transmitter
  @transmitter ||= Transmitter.new(
    "#{Appsignal.config[:logging_endpoint]}/check_ins/json"
  )
end