X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fjob_queue_monitor.ex;h=b5f124923101d9c54b6557034e4eeb78ee6bf3ac;hb=1b79dce7bc53f0aa6ce07fdc178bb72b5caabe98;hp=2ecf261f387e7a42b9643864b58489caa3eef174;hpb=c466e739b6cfe21e68fb10805f7747ea74d76f74;p=akkoma
diff --git a/lib/pleroma/job_queue_monitor.ex b/lib/pleroma/job_queue_monitor.ex
index 2ecf261f3..b5f124923 100644
--- a/lib/pleroma/job_queue_monitor.ex
+++ b/lib/pleroma/job_queue_monitor.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.JobQueueMonitor do
@@ -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