Improve error reporting and add test

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-08-03 12:15:54 +02:00
parent ec745b3e80
commit cceb083ad7
4 changed files with 107 additions and 8 deletions

View File

@@ -28,6 +28,16 @@ defmodule Mobilizon.Service.ErrorReporting.Sentry do
end
end
@impl ErrorReporting
def attach do
:telemetry.attach(
"oban-errors",
[:oban, :job, :exception],
&handle_event/4,
[]
)
end
@impl ErrorReporting
def handle_event([:oban, :job, :exception], measure, %{job: job} = meta, _) do
extra =
@@ -42,4 +52,6 @@ defmodule Mobilizon.Service.ErrorReporting.Sentry do
def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
end
def handle_event(_, _, _, _), do: :ok
end