Skip to content

Commit bc3a249

Browse files
committed
define finch opts and update logger/send_test_event tests
1 parent c51cef6 commit bc3a249

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed

config/config.exs

Lines changed: 4 additions & 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-
hackney_opts: [recv_timeout: 50, pool: :sentry_pool],
9+
finch_request_opts: [receive_timeout: 50],
1010
send_result: :sync,
1111
send_max_attempts: 1,
1212
dedup_events: false,
@@ -22,3 +22,6 @@ if config_env() == :test do
2222
end
2323

2424
config :phoenix, :json_library, if(Code.ensure_loaded?(JSON), do: JSON, else: Jason)
25+
26+
config :sentry,
27+
client: Sentry.FinchClient

lib/mix/tasks/sentry.send_test_event.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
6767
end
6868

6969
Mix.shell().info("current environment_name: #{inspect(to_string(Config.environment_name()))}")
70-
Mix.shell().info("hackney_opts: #{inspect(Config.hackney_opts())}\n")
70+
Mix.shell().info("finch_pool_opts: #{inspect(Config.finch_pool_opts())}\n")
7171
end
7272

7373
defp send_event(opts) do

lib/sentry/config.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ defmodule Sentry.Config do
366366
The maximum number of attempts to send an event to Sentry.
367367
"""
368368
],
369-
finch_opts: [
369+
finch_pool_opts: [
370370
type: :keyword_list,
371371
default: [size: 50, conn_max_idle_time: 5000],
372372
doc: """

lib/sentry/finch_client.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Sentry.FinchClient do
2323
Finch.child_spec(
2424
name: __MODULE__,
2525
pools: %{
26-
:default => Sentry.Config.finch_opts()
26+
:default => Sentry.Config.finch_pool_opts()
2727
}
2828
)
2929
else
@@ -39,7 +39,7 @@ defmodule Sentry.FinchClient do
3939
def post(url, headers, body) do
4040
request = Finch.build(:post, url, headers, body)
4141

42-
case Finch.request(request, __MODULE__) do
42+
case Finch.request(request, __MODULE__, Sentry.Config.finch_request_opts()) do
4343
{:ok, %Finch.Response{status: status, headers: headers, body: body}} ->
4444
{:ok, status, headers, body}
4545

test/mix/sentry.send_test_event_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Mix.Tasks.Sentry.SendTestEventTest do
55
import Sentry.TestHelpers
66

77
test "prints if :dsn is not set" do
8-
put_test_config(dsn: nil, hackney_opts: [], environment_name: "some_env")
8+
put_test_config(dsn: nil, finch_pool_opts: [], environment_name: "some_env")
99

1010
output =
1111
capture_io(fn ->
@@ -15,7 +15,7 @@ defmodule Mix.Tasks.Sentry.SendTestEventTest do
1515
assert output =~ """
1616
Client configuration:
1717
current environment_name: "some_env"
18-
hackney_opts: []
18+
finch_pool_opts: []
1919
"""
2020

2121
assert output =~ ~s(Event not sent because the :dsn option is not set)
@@ -35,7 +35,7 @@ defmodule Mix.Tasks.Sentry.SendTestEventTest do
3535
put_test_config(
3636
dsn: "http://public:secret@localhost:#{bypass.port}/1",
3737
environment_name: "test",
38-
hackney_opts: []
38+
finch_pool_opts: []
3939
)
4040

4141
output =
@@ -49,7 +49,7 @@ defmodule Mix.Tasks.Sentry.SendTestEventTest do
4949
public_key: public
5050
secret_key: secret
5151
current environment_name: "test"
52-
hackney_opts: []
52+
finch_pool_opts: []
5353
"""
5454

5555
assert output =~ "Sending test event..."

test/sentry/logger_handler_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ defmodule Sentry.LoggerHandlerTest do
686686
put_test_config(
687687
dsn: "http://public:secret@localhost:#{bypass.port}/1",
688688
dedup_events: false,
689-
hackney_opts: [recv_timeout: 500, pool: :sentry_pool]
689+
finch_request_opts: [receive_timeout: 500]
690690
)
691691

692692
Bypass.expect(bypass, fn conn ->

test/sentry_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule SentryTest do
5050
test "errors when taking too long to receive response", %{bypass: bypass} do
5151
Bypass.expect(bypass, fn _conn -> Process.sleep(:infinity) end)
5252

53-
put_test_config(hackney_opts: [recv_timeout: 50])
53+
put_test_config(finch_request_opts: [receive_timeout: 50])
5454

5555
assert {:error,
5656
%Sentry.ClientError{

0 commit comments

Comments
 (0)