Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default result type to :none #341

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/sentry/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ defmodule Sentry.Client do
The event is dropped if it all retries fail.

### 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.
"""
@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()

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

assert_receive "API called"
Expand Down