You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,14 +17,15 @@ If you would like to upgrade a project to use Sentry 7.x, see [here](https://gis
17
17
18
18
## Installation
19
19
20
-
To use Sentry with your projects, edit your mix.exs file and add it as a dependency. Sentry does not install a JSON library itself, and requires users to have one available. Sentry will default to trying to use Jason for JSON operations, but can be configured to use other ones.
20
+
To use Sentry with your projects, edit your mix.exs file and add it as a dependency. Sentry does not install a JSON library nor HTTP client by itself. Sentry will default to trying to use Jason for JSON operations and Hackney for HTTP requests, but can be configured to use other ones. To use the default ones, do:
21
21
22
22
```elixir
23
23
defpdepsdo
24
24
[
25
25
# ...
26
26
{:sentry, "~> 7.0"},
27
27
{:jason, "~> 1.1"},
28
+
{:hackney, "~> 1.8"}
28
29
]
29
30
end
30
31
```
@@ -116,13 +117,15 @@ The full range of options is the following:
116
117
|`tags`| False |`%{}`||
117
118
|`release`| False | None ||
118
119
|`server_name`| False | None ||
119
-
|`client`| False |`Sentry.Client`| If you need different functionality for the HTTP client, you can define your own module that implements the `Sentry.HTTPClient` behaviour and set `client` to that module |
120
+
|`client`| False |`Sentry.HackneyClient`| If you need different functionality for the HTTP client, you can define your own module that implements the `Sentry.HTTPClient` behaviour and set `client` to that module |
120
121
|`hackney_opts`| False |`[pool: :sentry_pool]`||
121
122
|`hackney_pool_max_connections`| False | 50 ||
122
123
|`hackney_pool_timeout`| False | 5000 ||
123
124
|`before_send_event`| False |||
124
125
|`after_send_event`| False |||
125
126
|`sample_rate`| False | 1.0 ||
127
+
|`send_result`| False |`:none`| You may want to set it to `:sync` if testing your Sentry integration. See "Testing with Sentry" |
128
+
|`send_max_attempts`| False | 4 ||
126
129
|`in_app_module_whitelist`| False |`[]`||
127
130
|`report_deps`| False | True | Will attempt to load Mix dependencies at compile time to report alongside events |
128
131
|`enable_source_code_context`| False | False ||
@@ -242,10 +245,13 @@ test "add/2 does not raise but sends an event to Sentry when given bad input" do
Copy file name to clipboardExpand all lines: lib/sentry.ex
+7-9Lines changed: 7 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -75,14 +75,17 @@ defmodule Sentry do
75
75
76
76
## Capturing Exceptions
77
77
78
-
Simply calling `capture_exception/2` will send the event. By default, the event is sent asynchronously and the result can be awaited upon. The `:result` option can be used to change this behavior. See `Sentry.Client.send_event/2` for more information.
78
+
Simply calling `capture_exception/2` will send the event. By default, the event
79
+
is sent asynchronously and the result can be awaited upon. The `:result` option
80
+
can be used to change this behavior. See `Sentry.Client.send_event/2` for more
Copy file name to clipboardExpand all lines: lib/sentry/client.ex
+60-50Lines changed: 60 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -1,39 +1,49 @@
1
1
defmoduleSentry.Clientdo
2
-
@behaviourSentry.HTTPClient
3
-
# Max message length per https://github.com/getsentry/sentry/blob/0fcec33ac94ad81a205f86f208072b0f57b39ff4/src/sentry/conf/server.py#L1021
4
-
@max_message_length8_192
5
-
6
2
@moduledoc~S"""
7
-
This module is the default client for sending an event to Sentry via HTTP.
3
+
This module interfaces directly with Sentry via HTTP.
8
4
9
-
It makes use of `Task.Supervisor` to allow sending tasks synchronously or asynchronously, and defaulting to asynchronous. See `Sentry.Client.send_event/2` for more information.
5
+
The client itself can be configured via the :client
6
+
configuration. It must implement the `Sentry.HTTPClient`
7
+
behaviour and it defaults to `Sentry.HackneyClient`.
8
+
9
+
It makes use of `Task.Supervisor` to allow sending tasks
10
+
synchronously or asynchronously, and defaulting to asynchronous.
11
+
See `send_event/2` for more information.
10
12
11
13
### Configuration
12
14
13
-
* `:before_send_event` - allows performing operations on the event before
14
-
it is sent. Accepts an anonymous function or a {module, function} tuple, and
15
-
the event will be passed as the only argument.
15
+
* `:before_send_event` - allows performing operations on the event before
16
+
it is sent. Accepts an anonymous function or a `{module, function}` tuple,
17
+
and the event will be passed as the only argument.
16
18
17
-
* `:after_send_event` - callback that is called after attempting to send an event.
18
-
Accepts an anonymous function or a {module, function} tuple. The result of the HTTP call as well as the event will be passed as arguments.
19
-
The return value of the callback is not returned.
19
+
* `:after_send_event` - callback that is called after attempting to send an event.
20
+
Accepts an anonymous function or a `{module, function}` tuple. The result of the
21
+
HTTP call as well as the event will be passed as arguments. The return value of
22
+
the callback is not returned.
20
23
21
24
Example configuration of putting Logger metadata in the extra context:
# Max message length per https://github.com/getsentry/sentry/blob/0fcec33ac94ad81a205f86f208072b0f57b39ff4/src/sentry/conf/server.py#L1021
61
+
@max_message_length8_192
54
62
55
63
@doc"""
56
64
Attempts to send the event to the Sentry API up to 4 times with exponential backoff.
57
65
58
66
The event is dropped if it all retries fail.
59
-
Errors will be logged unless the source is the Sentry.LoggerBackend, which can deadlock by logging within a logger.
67
+
Errors will be logged unless the source is the Sentry.LoggerBackend, which can
68
+
deadlock by logging within a logger.
60
69
61
70
### Options
62
-
* `: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.
63
-
* `: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.
64
-
* 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.
71
+
72
+
* `:result` - Allows specifying how the result should be returned. Options include
73
+
`:sync`, `:none`, and `:async`. `:sync` will make the API call synchronously, and
74
+
return `{:ok, event_id}` if successful. `:none` sends the event from an unlinked
75
+
child process under `Sentry.TaskSupervisor` and will return `{:ok, ""}` regardless
76
+
of the result. `:async` will start an unlinked task and return a tuple of `{:ok, Task.t}`
77
+
on success where the Task should be awaited upon to receive the result asynchronously.
78
+
If you do not call `Task.await/2`, messages will be leaked to the inbox of the current
79
+
process. See `Task.Supervisor.async_nolink/2` for more information. `:none` is the default.
80
+
81
+
* `:sample_rate` - The sampling factor to apply to events. A value of 0.0 will deny sending
82
+
any events, and a value of 1.0 will send 100% of events.
83
+
84
+
* Other options, such as `:stacktrace` or `:extra` will be passed to `Sentry.Event.create_event/1`
85
+
downstream. See `Sentry.Event.create_event/1` for available options.
0 commit comments