Expand oban error tracking for plugins/notifiers (#1864)

* Plugin exceptions may be silently covering up database problems such
  as failed cron job inserts.
* The previously tracked `:circuit` event is no longer emitted.
This commit is contained in:
Parker Selbert 2022-04-27 13:37:02 -05:00 committed by GitHub
parent ce55dc4ae9
commit a64cc84db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -47,7 +47,7 @@ defmodule Plausible.Application do
:telemetry.attach_many(
"oban-errors",
[[:oban, :job, :exception], [:oban, :circuit, :trip]],
[[:oban, :job, :exception], [:oban, :notifier, :exception], [:oban, :plugin, :exception]],
&ErrorReporter.handle_event/4,
%{}
)

View File

@ -7,11 +7,19 @@ defmodule ErrorReporter do
on_job_exception(job)
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: extra)
Sentry.capture_exception(meta.reason, stacktrace: meta.stacktrace, extra: extra)
end
def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
def handle_event([:oban, :notifier, :exception], _timing, meta, _) do
extra = Map.take(meta, ~w(channel payload)a)
Sentry.capture_exception(meta.reason, stacktrace: meta.stacktrace, extra: extra)
end
def handle_event([:oban, :plugin, :exception], _timing, meta, _) do
extra = Map.take(meta, ~w(plugin)a)
Sentry.capture_exception(meta.reason, stacktrace: meta.stacktrace, extra: extra)
end
defp on_job_exception(%Oban.Job{