View Source ExHealth (ex_health v0.4.0)

ExHealth is a simple extensible health check utility that monitors your applications.

Link to this section Summary

Functions

Defines a healthcheck function.

Defines a healthcheck function for a given process.

Starts the application with empty state.

Callback implementation for Application.start/2.

Synchronously fetches the latest status from ExHealth.HealthServer.

Stops the Application.

Link to this section Functions

Link to this macro

health_check(name, list)

View Source (macro)

Defines a healthcheck function.

Takes the following arguments:

  • :name - a string for the name of the health check
  • :block - block that returns :ok | true | {:error, "Reason"}

examples

Examples

defmodule MyApp.HealthChecks do
  health_check("Database") do
    MyDB.ping() # This should return  :ok | true | {:error, "Reason"}
  end
end
Link to this macro

process_check(module)

View Source (macro)

Defines a healthcheck function for a given process.

Returns :ok if the process has one of the following statuses:

  • :running
  • :waiting

See Process.info/1 for more information about process status.

examples

Examples

defmodule MyApp.HealthChecks do
  process_check(MyApp.SomeImportantService)
end

Starts the application with empty state.

Callback implementation for Application.start/2.

@spec status() :: ExHealth.Status.t()

Synchronously fetches the latest status from ExHealth.HealthServer.

examples

Examples

iex> ExHealth.status()
%ExHealth.Status{
  checks: [
    %ExHealth.Check{
      mfa: {ExHealth.SelfCheck, :hc__ExHealth_HealthServer, []},
      name: "ExHealth_HealthServer"
    }
  ],
  interval_ms: 15000,
  last_check: nil,
  result: %{check_results: [], msg: :pending}
}
@spec stop() :: :ok

Stops the Application.