Skip to content

Commit 20f4684

Browse files
committed
use task supervisor and wait for task to finish
1 parent 5cdb12f commit 20f4684

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/mix/tasks/sentry.send_test_event.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
3232
if env_name in included_envs do
3333
Mix.shell.info "Sending test event!"
3434
Sentry.capture_exception(RuntimeError.exception("Testing sending Sentry event"))
35+
|> Task.await()
3536
else
3637
Mix.shell.info "#{inspect env_name} is not in #{inspect included_envs} so no test event will be sent"
3738
end

lib/sentry.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule Sentry do
22
use Application
3-
3+
import Supervisor.Spec
44
alias Sentry.Event
55
require Logger
66

@@ -66,7 +66,9 @@ defmodule Sentry do
6666
@use_error_logger Application.get_env(:sentry, :use_error_logger, false)
6767

6868
def start(_type, _opts) do
69-
children = []
69+
children = [
70+
supervisor(Task.Supervisor, [[name: Sentry.TaskSupervisor]]),
71+
]
7072
opts = [strategy: :one_for_one, name: Sentry.Supervisor]
7173

7274

lib/sentry/client.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule Sentry.Client do
2626
auth_headers = authorization_headers(public_key, secret_key)
2727
body = Poison.encode!(event)
2828

29-
Task.start(fn ->
29+
Task.Supervisor.async_nolink(Sentry.TaskSupervisor, fn ->
3030
try_request(:post, endpoint, auth_headers, body)
3131
end)
3232
end

0 commit comments

Comments
 (0)