Sending check-in events using the AppSignal integrations

The AppSignal integrations for Ruby, Elixir, Node.js and Python offer helper methods and functions that allow you to easily send check-in events to AppSignal.

Cron check-in events

This feature requires AppSignal for Ruby version 3.13.0 or higher.
This feature requires AppSignal for Elixir version 2.12.2 or higher.
This feature requires AppSignal for Node.js version 3.4.9 or higher.
This feature requires AppSignal for Python version 1.3.8 or higher.

To notify AppSignal that a cron job has finished successfully, use the cron helper function, passing the name of the cron check-in as an argument.

Ruby
Elixir
Nodejs
Python
Ruby
def send_invoices # ... your code here ... Appsignal::CheckIn.cron("send_invoices") end
Elixir
def send_invoices do # ... your code here ... Appsignal.CheckIn.cron("send_invoices") end
Nodejs
import { checkIn } from "@appsignal/nodejs"; function sendInvoices() { // ... your code here ... checkIn.cron("send_invoices"); }
Python
from appsignal.check_in import cron def send_invoices(): # ... your code here ... cron("send_invoices")

It is safe to call the cron helper function many times in a short period, as the helper will only send a finish event to AppSignal at most once every ten seconds.

Monitoring the job's duration

To monitor the duration of a cron job, you can use the cron helper function with a block or function that contains the code you want to monitor. This will send events to AppSignal both when the job starts and when it finishes.

Ruby
Elixir
Nodejs
Python
Ruby
def send_invoices() Appsignal::CheckIn.cron("send_invoices") do # ... your code here ... end end
Elixir
def send_invoices do Appsignal.CheckIn.cron("send_invoices", fn -> # ... your code here ... end) end
Nodejs
import { checkIn } from "@appsignal/nodejs"; function sendInvoices() { checkIn.cron("send_invoices", () => { // ... your code here ... }); } // If the function passed to `cron` returns a promise, the finish event // will be reported to AppSignal if the promise resolves, allowing you // to track the duration of async functions: async function sendInvoices() { await checkIn.cron("send_invoices", async () => { // ... your async code here ... }); } // If the promise is rejected, or if it never resolves, the finish event // will not be reported to AppSignal.
Python
from appsignal.check_in import Cron def send_invoices(): with Cron("send_invoices"): # ... your code here ...

If an exception is raised within the function or method being monitored, the finish event will not be reported to AppSignal, triggering a missing check-in notification. The exception will be re-raised.

If the context in which the exception is raised is an AppSignal-monitored context, then the exception will be reported to AppSignal. Otherwise, if you wish to report the exception to AppSignal, you can use our exception handling helpers for Ruby, Elixir, Node.js or Python.

Heartbeat check-in events

This feature requires AppSignal for Ruby version 4.1.0 or higher.
This feature requires AppSignal for Elixir version 2.13.0 or higher.
This feature requires AppSignal for Node.js version 3.5.0 or higher.
This feature requires AppSignal for Python version 1.4.0 or higher.

To send a heartbeat check-in event to AppSignal, use the heartbeat helper function, passing the name of the heartbeat check-in as an argument.

It is safe to call heartbeat many times, as the helper will only send a heartbeat event to AppSignal at most every ten seconds.

Ruby
Elixir
Nodejs
Python
Ruby
loop do Appsignal::CheckIn.heartbeat("job_processor") # ... your code here ... end
Elixir
def job_processing_loop do Appsignal.CheckIn.heartbeat("job_processor") # ... your code here ... job_processing_loop() end
Nodejs
import { checkIn } from "@appsignal/nodejs"; while (true) { checkIn.heartbeat("job_processor"); // ... your code here ... }
Python
from appsignal.check_in import heartbeat while True: heartbeat("job_processor") # ... your code here ...

Sending heartbeats continuously

To send heartbeat check-ins continuously, you can pass the { continuous: true } option to the heartbeat helper function. This is useful to monitor the lifetime of the process itself. The helper will send a heartbeat event to AppSignal every thirty seconds.

Ruby
Elixir
Nodejs
Python
Ruby
Appsignal::CheckIn.heartbeat("job_processor", continuous: true)
Elixir
# This call spawns a new Elixir process, linked to the current process. # If the current process exits, the heartbeat process will also exit. Appsignal.CheckIn.heartbeat("job_processor", continuous: true) # It is also possible to add a continuous heartbeat sending process # to a supervision tree. This will ensure that the process is restarted # alongside the rest of the supervised children. Supervisor.start_link([ {Appsignal.CheckIn.Heartbeat, "job_processor"}, # ... other children processes ... ], strategy: :one_for_one)
Nodejs
import { checkIn } from "@appsignal/nodejs"; checkIn.heartbeat("job_processor", { continuous: true });
Python
from appsignal.check_in import heartbeat heartbeat("my_app", continuous=True)

Reviewing check-in occurrences in AppSignal

Once configured, AppSignal will begin to display information about occurrences for your check-ins.

You can read more about occurrences in our Check-in occurrences documentation.