diff --git a/lib/sentry/client.ex b/lib/sentry/client.ex index 2b79fe03..ea679e63 100644 --- a/lib/sentry/client.ex +++ b/lib/sentry/client.ex @@ -59,13 +59,13 @@ defmodule Sentry.Client do Errors will be logged unless the source is the Sentry.LoggerBackend, which can deadlock by logging within a logger. ### Options - * `:result` - Allows specifying how the result should be returned. Options include `:sync`, `:none`, and `:async`. `:sync` will make the API call synchronously, and return `{:ok, event_id}` if successful. `:none` sends the event from an unlinked child process under `Sentry.TaskSupervisor` and will return `{:ok, ""}` regardless of the result. `:async` will start an unlinked task and return a tuple of `{:ok, Task.t}` on success where the Task can be awaited upon to receive the result asynchronously. When used in an OTP behaviour like GenServer, the task will send a message that needs to be matched with `GenServer.handle_info/2`. See `Task.Supervisor.async_nolink/2` for more information. `:async` is the default. + * `:result` - Allows specifying how the result should be returned. Options include `:sync`, `:none`, and `:async`. `:sync` will make the API call synchronously, and return `{:ok, event_id}` if successful. `:none` sends the event from an unlinked child process under `Sentry.TaskSupervisor` and will return `{:ok, ""}` regardless of the result. `:async` will start an unlinked task and return a tuple of `{:ok, Task.t}` on success where the Task should be awaited upon to receive the result asynchronously. If you do not call `Task.await/2`, messages will be leaked to the inbox of the current process. See `Task.Supervisor.async_nolink/2` for more information. `:none` is the default. * `:sample_rate` - The sampling factor to apply to events. A value of 0.0 will deny sending any events, and a value of 1.0 will send 100% of events. * Other options, such as `:stacktrace` or `:extra` will be passed to `Sentry.Event.create_event/1` downstream. See `Sentry.Event.create_event/1` for available options. """ @spec send_event(Event.t()) :: send_event_result def send_event(%Event{} = event, opts \\ []) do - result = Keyword.get(opts, :result, :async) + result = Keyword.get(opts, :result, :none) sample_rate = Keyword.get(opts, :sample_rate) || Config.sample_rate() should_log = event.event_source != :logger diff --git a/test/client_test.exs b/test/client_test.exs index 835c5cef..ac196708 100644 --- a/test/client_test.exs +++ b/test/client_test.exs @@ -334,7 +334,8 @@ defmodule Sentry.ClientTest do {:ok, task} = Sentry.capture_exception( e, - stacktrace: __STACKTRACE__ + stacktrace: __STACKTRACE__, + result: :async ) assert_receive "API called"