diff options
author | rinpatch <rinpatch@sdf.org> | 2020-08-12 03:30:01 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-08-12 03:30:01 +0000 |
commit | 86c18e4165f1b247af11360535a9daa6ce1641d3 (patch) | |
tree | 0e718a4714cd9ab80106bac17735905f199c5bad | |
parent | c66f6bd0ad130eb59c3c1e7edfbbddddf6772864 (diff) | |
parent | 76462efbfaa4bc01ca80cb702161b3197968c584 (diff) | |
download | pleroma-86c18e4165f1b247af11360535a9daa6ce1641d3.tar.gz |
Merge branch 'issue/2036-job-monitor' into 'develop'
[#2036] fix job monitor
See merge request pleroma/pleroma!2877
-rw-r--r-- | lib/pleroma/job_queue_monitor.ex | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/pleroma/job_queue_monitor.ex b/lib/pleroma/job_queue_monitor.ex index 2ecf261f3..c255a61ec 100644 --- a/lib/pleroma/job_queue_monitor.ex +++ b/lib/pleroma/job_queue_monitor.ex @@ -15,8 +15,8 @@ defmodule Pleroma.JobQueueMonitor do @impl true def init(state) do - :telemetry.attach("oban-monitor-failure", [:oban, :failure], &handle_event/4, nil) - :telemetry.attach("oban-monitor-success", [:oban, :success], &handle_event/4, nil) + :telemetry.attach("oban-monitor-failure", [:oban, :job, :exception], &handle_event/4, nil) + :telemetry.attach("oban-monitor-success", [:oban, :job, :stop], &handle_event/4, nil) {:ok, state} end @@ -25,8 +25,11 @@ defmodule Pleroma.JobQueueMonitor do GenServer.call(__MODULE__, :stats) end - def handle_event([:oban, status], %{duration: duration}, meta, _) do - GenServer.cast(__MODULE__, {:process_event, status, duration, meta}) + def handle_event([:oban, :job, event], %{duration: duration}, meta, _) do + GenServer.cast( + __MODULE__, + {:process_event, mapping_status(event), duration, meta} + ) end @impl true @@ -75,4 +78,7 @@ defmodule Pleroma.JobQueueMonitor do |> Map.update!(:processed_jobs, &(&1 + 1)) |> Map.update!(status, &(&1 + 1)) end + + defp mapping_status(:stop), do: :success + defp mapping_status(:exception), do: :failure end |