← Changelog

Heartbeat check-ins and other improvements

Sep 26, 2024
Elixir2.13.0

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 a GenServer'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

    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 a GenServer's initialisation:

    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 an Application'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

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.

$appsignal install

Make your next crash make sense.

Free for 30 days. No credit card. Two-minute install.