Skip to content

Commit

Permalink
Merge pull request #341 from getsentry/change-default-send-behaviour
Browse files Browse the repository at this point in the history
default result type to :none
  • Loading branch information
mitchellhenke authored Jun 9, 2020
2 parents 5cbfab2 + 43906ac commit 45f83d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ defmodule Sentry.ClientTest do
{:ok, task} =
Sentry.capture_exception(
e,
stacktrace: __STACKTRACE__
stacktrace: __STACKTRACE__,
result: :async
)

assert_receive "API called"
Expand Down

0 comments on commit 45f83d6

Please sign in to comment.