Skip to content

Commit 98f5ac6

Browse files
authored
Changed where hackney compiles its metrics module (#2)
Under erlang 20, compilation is slower, and compiling the metrics module when a connection is created doesn't make sense, as this can cause the whole code server to become buried under recompilation requests. This moves compilation to the application's start.
1 parent 107f242 commit 98f5ac6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/hackney_app.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
%% ===================================================================
2121

2222
start(_StartType, _StartArgs) ->
23+
Metrics = metrics:init(hackney_util:mod_metrics()),
24+
application:set_env(hackney, metrics, Metrics),
2325
hackney_sup:start_link().
2426

2527
stop(_State) ->

src/hackney_connect.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ create_connection(Transport, Host, Port, Options, Dynamic)
6666
MaxBody = proplists:get_value(max_body, Options),
6767

6868
%% get mod metrics
69-
Engine = metrics:init(hackney_util:mod_metrics()),
69+
{ok, Engine} = application:get_env(hackney, metrics),
7070

7171
%% initial state
7272
InitialState = #client{mod_metrics=Engine,

0 commit comments

Comments
 (0)