From a64cc84db267bce5cc1453ccb157b26a62d12667 Mon Sep 17 00:00:00 2001 From: Parker Selbert Date: Wed, 27 Apr 2022 13:37:02 -0500 Subject: [PATCH] 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. --- lib/plausible/application.ex | 2 +- lib/telemetry.ex | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/plausible/application.ex b/lib/plausible/application.ex index 07f43d93b..1f3faf671 100644 --- a/lib/plausible/application.ex +++ b/lib/plausible/application.ex @@ -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, %{} ) diff --git a/lib/telemetry.ex b/lib/telemetry.ex index e60a91366..ea052ad17 100644 --- a/lib/telemetry.ex +++ b/lib/telemetry.ex @@ -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{