Skip to content

Commit 9b5a40d

Browse files
committed
Auto attach Oban if present
1 parent d69ed4d commit 9b5a40d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/error_tracker/application.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ defmodule ErrorTracker.Application do
44
def start(_type, _args) do
55
children = []
66

7+
attach_handlers()
8+
79
Supervisor.start_link(children, strategy: :one_for_one, name: __MODULE__)
810
end
11+
12+
defp attach_handlers do
13+
ErrorTracker.Integrations.Oban.attach()
14+
end
915
end

lib/error_tracker/integrations/oban.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
defmodule ErrorTracker.Integrations.Oban do
22
def attach do
3-
:telemetry.attach(__MODULE__, [:oban, :job, :exception], &handle_event/4, :no_config)
3+
if Application.spec(:oban) do
4+
:telemetry.attach(__MODULE__, [:oban, :job, :exception], &handle_event/4, :no_config)
5+
end
46
end
57

68
def handle_event([:oban, :job, :exception], _measurements, metadata, :no_config) do

0 commit comments

Comments
 (0)