Skip to content

Commit 97efd6c

Browse files
committed
correct test and doc
1 parent 7484091 commit 97efd6c

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ This is the official Sentry SDK for [Sentry].
2020

2121
To use Sentry in your project, add it as a dependency in your `mix.exs` file.
2222

23-
Sentry does not install a JSON library nor an HTTP client by itself. Sentry will default to the [built-in `JSON`](https://hexdocs.pm/elixir/JSON.html) for JSON and [Hackney] for HTTP requests, but can be configured to use other ones. To use the default ones, do:
23+
Sentry does not install a JSON library nor an HTTP client by itself. Sentry will default to the [built-in `JSON`](https://hexdocs.pm/elixir/JSON.html) for JSON and [Finch] for HTTP requests, but can be configured to use other ones. To use the default ones, do:
2424

2525
```elixir
2626
defp deps do
2727
[
2828
# ...
2929

30-
{:sentry, "~> 10.8"},
31-
{:hackney, "~> 1.20"}
30+
{:sentry, "~> 10.0"},
31+
{:jason, "~> 1.4"},
32+
{:finch, "~> 0.18"}
3233
]
3334
end
3435
```
@@ -203,7 +204,7 @@ Licensed under the MIT license, see [`LICENSE`](./LICENSE).
203204

204205
[Sentry]: http://sentry.io/
205206
[Jason]: https://github.com/michalmuskala/jason
206-
[Hackney]: https://github.com/benoitc/hackney
207+
[Finch]: https://github.com/sneako/finch
207208
[Bypass]: https://github.com/PSPDFKit-labs/bypass
208209
[docs]: https://hexdocs.pm/sentry/readme.html
209210
[logger-handlers]: https://www.erlang.org/doc/apps/kernel/logger_chapter#handlers

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if config_env() == :test do
66
tags: %{},
77
enable_source_code_context: true,
88
root_source_code_paths: [File.cwd!()],
9-
finch_opts: [recv_timeout: 50, pool: :sentry_pool],
9+
finch_opts: [recv_timeout: 50],
1010
send_result: :sync,
1111
send_max_attempts: 1,
1212
dedup_events: false,

lib/sentry/finch_client.ex

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ defmodule Sentry.FinchClient do
1111
HTTP client, you'll have to implement your own `Sentry.HTTPClient`. See the
1212
documentation for `Sentry.HTTPClient` for more information.
1313
14-
Sentry starts its own finch pool called `:sentry_pool`. If you need to set other
15-
[hackney configuration options](https://github.com/benoitc/hackney/blob/master/doc/hackney.md#request5)
16-
for things such as proxies, using your own pool, or response timeouts, the `:finch_opts`
17-
configuration is passed directly to hackney for each request. See the configuration
18-
documentation in the `Sentry` module.
14+
Finch is built on top of NimblePool. If you need to set other pool configuration options,
15+
see "Pool Configuration Options" in the source code for details on the possible map values.
16+
[finch configuration options](https://github.com/sneako/finch/blob/main/lib/finch.ex)
1917
"""
20-
@finch_pool_name :sentry_pool
21-
2218
@impl true
2319
def child_spec do
2420
if Code.ensure_loaded?(Finch) do
@@ -49,11 +45,7 @@ defmodule Sentry.FinchClient do
4945
def post(url, headers, body) do
5046
request = Finch.build(:post, url, headers, body)
5147

52-
finch_opts =
53-
Sentry.Config.finch_opts()
54-
|> Keyword.put_new(:pool, @finch_pool_name)
55-
56-
case Finch.request(request, __MODULE__, finch_opts) do
48+
case Finch.request(request, __MODULE__) do
5749
{:ok, %Finch.Response{status: status, headers: headers, body: body}} ->
5850
{:ok, status, headers, body}
5951

test/logger_backend_test.exs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ defmodule Sentry.LoggerBackendTest do
136136

137137
start_supervised!(Sentry.ExamplePlugApplication, restart: :temporary)
138138

139-
:hackney.get("http://127.0.0.1:8003/error_route", [], "", [])
139+
Finch.build(:get, "http://127.0.0.1:8003/error_route", [], "", [])
140+
|> Finch.request(Sentry.FinchClient)
141+
140142
assert_receive {^ref, _event}, 1000
141143
after
142144
Logger.configure_backend(Sentry.LoggerBackend, excluded_domains: [:cowboy, :bandit])
@@ -149,7 +151,9 @@ defmodule Sentry.LoggerBackendTest do
149151

150152
start_supervised!({Sentry.ExamplePlugApplication, server: :bandit}, restart: :temporary)
151153

152-
:hackney.get("http://127.0.0.1:8003/error_route", [], "", [])
154+
Finch.build(:get, "http://127.0.0.1:8003/error_route", [], "", [])
155+
|> Finch.request(Sentry.FinchClient)
156+
153157
assert_receive {^ref, _event}, 1000
154158
after
155159
Logger.configure_backend(Sentry.LoggerBackend, excluded_domains: [:cowboy, :bandit])

test/sentry/logger_handler_test.exs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ defmodule Sentry.LoggerHandlerTest do
9090

9191
test "TODO", %{sender_ref: ref} do
9292
start_supervised!(Sentry.ExamplePlugApplication, restart: :temporary)
93-
:hackney.get("http://127.0.0.1:8003/error_route", [], "", [])
93+
94+
Finch.build(:get, "http://127.0.0.1:8003/error_route", [], "", [])
95+
|> Finch.request(Sentry.FinchClient)
96+
9497
assert_receive {^ref, event}, 1000
9598
assert event.original_exception == %RuntimeError{message: "Error"}
9699
end
@@ -100,7 +103,8 @@ defmodule Sentry.LoggerHandlerTest do
100103
%{sender_ref: ref} do
101104
start_supervised!(Sentry.ExamplePlugApplication, restart: :temporary)
102105

103-
:hackney.get("http://127.0.0.1:8003/error_route", [], "", [])
106+
Finch.build(:get, "http://127.0.0.1:8003/error_route", [], "", [])
107+
|> Finch.request(Sentry.FinchClient)
104108

105109
assert_receive {^ref, event}, 1000
106110
assert event.original_exception == %RuntimeError{message: "Error"}
@@ -114,7 +118,8 @@ defmodule Sentry.LoggerHandlerTest do
114118
%{sender_ref: ref} do
115119
start_supervised!({Sentry.ExamplePlugApplication, server: :bandit}, restart: :temporary)
116120

117-
:hackney.get("http://127.0.0.1:8003/error_route", [], "", [])
121+
Finch.build(:get, "http://127.0.0.1:8003/error_route", [], "", [])
122+
|> Finch.request(Sentry.FinchClient)
118123

119124
assert_receive {^ref, _event}, 1000
120125
end

0 commit comments

Comments
 (0)