diff --git a/changelog.md b/changelog.md index 2f328ce..5a98c54 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # ehttpc changes +## 0.7.1 + +- Add `pool` and `id` to the worker process label. + ## 0.7.0 - Switch to `gun` 2.1.0. diff --git a/src/ehttpc.app.src b/src/ehttpc.app.src index e0b5f45..73d9706 100644 --- a/src/ehttpc.app.src +++ b/src/ehttpc.app.src @@ -1,6 +1,6 @@ {application, ehttpc, [ {description, "HTTP Client for Erlang/OTP"}, - {vsn, "0.7.0"}, + {vsn, "0.7.1"}, {registered, []}, {applications, [ kernel, diff --git a/src/ehttpc.erl b/src/ehttpc.erl index 7754703..42024d9 100644 --- a/src/ehttpc.erl +++ b/src/ehttpc.erl @@ -19,6 +19,10 @@ -behaviour(gen_server). +%% proc_lib:set_label/1 is not exported before OTP 27 +-dialyzer([{nowarn_function, [init/1]}]). +-ignore_xref({proc_lib, set_label, 1}). + %% APIs -export([ start_link/3, @@ -262,6 +266,13 @@ init([Pool, Id, Opts0]) -> max_inactive = MaxInactive }, true = gproc_pool:connect_worker(ehttpc:name(Pool), {Pool, Id}), + + case erlang:function_exported(proc_lib, set_label, 1) of + true -> + proc_lib:set_label({ehttpc, Pool, Id}); + false -> + ignore + end, {ok, start_check_inactive_timer(State)}. handle_call({health_check, _}, _From, State = #state{gun_state = up}) -> @@ -736,7 +747,9 @@ maybe_shoot( ]), inactive_duration_threshold => MaxInactive, inflight_requests => SentCount, - connection_pid => Client + connection_pid => Client, + pool => State#state.pool, + id => State#state.id }, State ), diff --git a/src/ehttpc_worker_sup.erl b/src/ehttpc_worker_sup.erl index e4d5156..1674831 100644 --- a/src/ehttpc_worker_sup.erl +++ b/src/ehttpc_worker_sup.erl @@ -28,7 +28,7 @@ start_link(Pool, Opts) -> init([Pool, Opts]) -> WorkerSpec = fun(Id) -> #{ - id => {worker, Id}, + id => {Pool, Id}, start => {ehttpc, start_link, [Pool, Id, Opts]}, restart => transient, shutdown => 5000,