Heartbeat check-ins and other improvements
Added
-
Add support for heartbeat check-ins.
Use the
checkIn.heartbeat
method to send a single heartbeat check-in event from your application. This can be used, for example, in your application's main loop:javascriptimport { checkIn } from "@appsignal/nodejs"; while (true) { checkIn.heartbeat("job_processor"); await processJob(); }
javascriptimport { checkIn } from "@appsignal/nodejs"; while (true) { checkIn.heartbeat("job_processor"); await processJob(); }
Heartbeats are deduplicated and sent asynchronously, without blocking the current thread. Regardless of how often the
.heartbeat
method is called, at most one heartbeat with the same identifier will be sent every ten seconds.Pass
{continuous: true}
as the second argument to send heartbeats continuously during the entire lifetime of the current process. This can be used, for example, after your application has finished its boot process:javascriptimport { checkIn } from "@appsignal/nodejs"; function main() { checkIn.heartbeat("job_processor", { continuous: true }); startApp(); }
javascriptimport { checkIn } from "@appsignal/nodejs"; function main() { checkIn.heartbeat("job_processor", { continuous: true }); startApp(); }
Changed
- Send check-ins concurrently. When calling
Appsignal.checkIn.cron
, instead of blocking the current process while the check-in events are sent, schedule them to be sent in a separate process. - Do not block Node.js shutdown. It is no longer necessary to call
Appsignal.stop
for the Node.js engine to allow itself to shut down. It should still be called and awaited in production scenarios and at the end of scripts, as it ensures that scheduled check-ins are delivered.
View the Node.js package v3.5.0 changelog for more information.