diff --git a/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex b/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex index c5604d899e..fedbc61644 100644 --- a/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex +++ b/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex @@ -22,6 +22,7 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do {mod, fun} = opts[:if] if apply(mod, fun, []) do + store_last_attempted_at_delay_metric() status_code = if healthy_state?(), do: 200, else: 503 conn @@ -40,6 +41,11 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do end end + def store_last_attempted_at_delay_metric do + value = DateTime.diff(oban_last_attempted_at(), DateTime.utc_now(), :second) + Appsignal.add_distribution_value("oban.last_attempted_at_delay", value) + end + def healthy_state? do app_started_recently?() or oban_attempted_jobs_recently?() end