Heartbeat check-ins and other improvements
Added
-
Add support for heartbeat check-ins.
Use the
Appsignal.CheckIn.heartbeat
method to send a single heartbeat check-in event from your application. This can be used, for example, in aGenServer
's callback:elixir@impl true def handle_cast({:process_job, job}, jobs) do Appsignal.CheckIn.heartbeat("job_processor") {:noreply, [job | jobs], {:continue, :process_job}} end
elixir@impl true def handle_cast({:process_job, job}, jobs) do Appsignal.CheckIn.heartbeat("job_processor") {:noreply, [job | jobs], {:continue, :process_job}} end
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, during aGenServer
's initialisation:elixir@impl true def init(_arg) do Appsignal.CheckIn.heartbeat("my_genserver", continuous: true) {:ok, nil} end
elixir@impl true def init(_arg) do Appsignal.CheckIn.heartbeat("my_genserver", continuous: true) {:ok, nil} end
You can also use
Appsignal.CheckIn.Heartbeat
as a supervisor's child process, in order for heartbeats to be sent continuously during the lifetime of the supervisor. This can be used, for example, during anApplication
's start:elixir@impl true def start(_type, _args) do Supervisor.start_link([ {Appsignal.CheckIn.Heartbeat, "my_application"} ], strategy: :one_for_one, name: MyApplication.Supervisor) end
elixir@impl true def start(_type, _args) do Supervisor.start_link([ {Appsignal.CheckIn.Heartbeat, "my_application"} ], strategy: :one_for_one, name: MyApplication.Supervisor) end
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.
View the Elixir package v2.13.0 changelog for more information.