Reporting Heartbeats via your AppSignal Integration
AppSignal offers helper methods/functions that send heartbeats automatically with the following integrations:
This documentation will explain how you can use AppSignal's helpers to send heartbeats from your app's processes.
Heartbeat types
Our helpers allow you to monitor background processes by sending AppSignal Start and Finish heartbeats:
- Start Heartbeat notify AppSignal that a process has started, its status will be updated to
Running
. - Finish Heartbeat notify AppSignal that a process has been completed, its status will be updated to:
Success
: if the process is completed within the Heartbeat's maximum job duration.Late
: if the process completes after the pre-defined maximum job duration.
Monitoring options
You can use AppSignal's helpers to either:
- Send a single Finish Heartbeat to notify AppSignal when a process is completed.
- Send two separate heartbeats: a Start Heartbeat to signal the start of a process and a Finish Heartbeat to signal its completion to AppSignal.
When sending both a Start and Finish Heartbeat AppSignal can report the actual run time of the process being monitored.
Send Finish Heartbeats
To send a Finish Heartbeat execute the heartbeat
helper function at the end of the process you are monitoring.
The heartbeat helper requires you to pass the name of the heartbeat you are monitoring, as it's defined in AppSignal.
For example, when sending a Finish Heartbeat from a process, with the Heartbeat name of send_invoices
:
def send_invoices do # ... your code here ... Appsignal.heartbeat("send_invoices") end
// Don't forget to import the `heartbeat` helper function: import { heartbeat } from "@appsignal/nodejs"; function sendInvoices() { // ... your code here ... heartbeat("send_invoices"); }
# Don't forget to import the `heartbeat` helper function from appsignal import heartbeat def send_invoices(): # ... your code here ... heartbeat("send_invoices")
def send_invoices # ... your code here ... Appsignal.heartbeat("send_invoices") end
Send Start and Finish Heartbeats
Depending on your programming language you can pass either a function or block to the heartbeat
helper to report when the process starts and finishes, allowing you to see the process duration.
def send_invoices do Appsignal.heartbeat("send_invoices", fn -> # ... your code here ... end) end
// Don't forget to import the `heartbeat` helper function. import { heartbeat } from "@appsignal/nodejs"; function sendInvoices() { heartbeat("send_invoices", () => { // ... your code here ... }); } // If the function passed to `heartbeat` returns a promise, the finish event will be reported to AppSignal if the promise resolves allowing you to track the duration of async functions: import { heartbeat } from "@appsignal/nodejs"; async function sendInvoices() { await heartbeat("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.
# Don't forget to import the `heartbeat` helper function. from appsignal import heartbeat def send_invoices(): # ... your code here ... heartbeat("send_invoices", send_invoices)
def send_invoices() Appsignal.heartbeat("send_invoices") do # ... your code here ... end end
Exceptions
If an exception is raised within the function or method being monitored, the finish event will not be reported to AppSignal, triggering a missing heartbeat notification.
If the process from where the exception is raised is an AppSignal supported integration then an exception will be reported to AppSignal independently from the heartbeat:
- Supported Elixir integrations
- Supported Node.js integrations
- Supported Python integrations
- Supported Ruby integrations
Reviewing heartbeats occurrences in AppSignal
Once configured AppSignal will begin to display occurrences information for your heartbeats.
You can read more about occurrences in our Heartbeat Occurrences documentation.