mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 08:16:16 +00:00
Merge branch 'issue/2036-job-monitor' into 'develop'
[#2036] fix job monitor See merge request pleroma/pleroma!2877
This commit is contained in:
commit
86c18e4165
|
@ -15,8 +15,8 @@ defmodule Pleroma.JobQueueMonitor do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def init(state) do
|
def init(state) do
|
||||||
:telemetry.attach("oban-monitor-failure", [:oban, :failure], &handle_event/4, nil)
|
:telemetry.attach("oban-monitor-failure", [:oban, :job, :exception], &handle_event/4, nil)
|
||||||
:telemetry.attach("oban-monitor-success", [:oban, :success], &handle_event/4, nil)
|
:telemetry.attach("oban-monitor-success", [:oban, :job, :stop], &handle_event/4, nil)
|
||||||
|
|
||||||
{:ok, state}
|
{:ok, state}
|
||||||
end
|
end
|
||||||
|
@ -25,8 +25,11 @@ defmodule Pleroma.JobQueueMonitor do
|
||||||
GenServer.call(__MODULE__, :stats)
|
GenServer.call(__MODULE__, :stats)
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event([:oban, status], %{duration: duration}, meta, _) do
|
def handle_event([:oban, :job, event], %{duration: duration}, meta, _) do
|
||||||
GenServer.cast(__MODULE__, {:process_event, status, duration, meta})
|
GenServer.cast(
|
||||||
|
__MODULE__,
|
||||||
|
{:process_event, mapping_status(event), duration, meta}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
@ -75,4 +78,7 @@ defmodule Pleroma.JobQueueMonitor do
|
||||||
|> Map.update!(:processed_jobs, &(&1 + 1))
|
|> Map.update!(:processed_jobs, &(&1 + 1))
|
||||||
|> Map.update!(status, &(&1 + 1))
|
|> Map.update!(status, &(&1 + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp mapping_status(:stop), do: :success
|
||||||
|
defp mapping_status(:exception), do: :failure
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue