Skip to content

Commit 3ac5fa5

Browse files
committed
goes back
1 parent f4aaa5b commit 3ac5fa5

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

lib/plausible/application.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ defmodule Plausible.Application do
2222
]
2323

2424
opts = [strategy: :one_for_one, name: Plausible.Supervisor]
25+
setup_sentry()
2526
setup_cache_stats()
2627
Location.load_all()
2728
Application.put_env(:plausible, :server_start, Timex.now())
@@ -33,6 +34,17 @@ defmodule Plausible.Application do
3334
:ok
3435
end
3536

37+
def setup_sentry() do
38+
Logger.add_backend(Sentry.LoggerBackend)
39+
40+
:telemetry.attach_many(
41+
"oban-errors",
42+
[[:oban, :job, :exception], [:oban, :circuit, :trip]],
43+
&ErrorReporter.handle_event/4,
44+
%{}
45+
)
46+
end
47+
3648
defp setup_cache_stats() do
3749
conf = Application.get_env(:plausible, :user_agent_cache)
3850

lib/telemetry.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defmodule ErrorReporter do
2+
def handle_event([:oban, :job, :exception], measure, %{job: job} = meta, _) do
3+
extra =
4+
job
5+
|> Map.take([:id, :args, :meta, :queue, :worker])
6+
|> Map.merge(measure)
7+
8+
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: extra)
9+
end
10+
11+
def handle_event([:oban, :circuit, :trip], _measure, meta, _) do
12+
Sentry.capture_exception(meta.error, stacktrace: meta.stacktrace, extra: meta)
13+
end
14+
end

0 commit comments

Comments
 (0)