Report scheduled jobs to HawkEye heartbeat monitors.
A heartbeat monitor expects a ping every period (for example once a day). When a ping is late, or the job reports a failure, HawkEye opens an incident and alerts you. HawkEye checks the deadline from outside your application, so it still alerts when your application, node or scheduler is down and nothing runs at all.
For Oban workers, configure HawkEye.Oban and no code changes are needed. For anything
else (Quantum jobs, GenServer timers, release tasks), call the functions in this module:
HawkEye.track(System.get_env("HAWKEYE_NIGHTLY_REPORT"), fn ->
MyApp.Reports.send_nightly()
end)A token is the monitor's ping token, or its whole ping URL copied from HawkEye
(https://hawkeye.observer/ping/<token>).
Delivery
Pings are sent in the background by default and never raise or block the caller: a
failed request is retried twice, then logged. Pass async: false to wait for the result.
Options
:message- text kept with the ping in HawkEye (for example the end of the job's output). HawkEye keeps the first 1,000 characters.:async-true(default) to send in the background and return:okat once;falseto wait and return:okor{:error, reason}.
Configuration
config :hawk_eye,
enabled: true, # false turns every ping into a no-op
base_url: "https://hawkeye.observer", # where bare tokens are sent
timeout: 10_000 # milliseconds per attempt
Summary
Functions
Reports the job's exit status: 0 is success, anything from 1 to 255 a failure.
Reports that the job failed. HawkEye opens an incident straight away.
Reports that the job ran successfully.
Runs fun, then reports success, or failure if it raises, throws or exits.
Types
Functions
Reports the job's exit status: 0 is success, anything from 1 to 255 a failure.
Reports that the job failed. HawkEye opens an incident straight away.
HawkEye.fail(token, message: Exception.message(error))
Reports that the job ran successfully.
Runs fun, then reports success, or failure if it raises, throws or exits.
The error is reraised after the failure is reported, so your own error handling is
unchanged. Returns what fun returns. A return value is never treated as a failure: call
fail/2 yourself if {:error, _} means the job failed.
Accepts the options of ping/2 except :message.