Skip to content

Commit 034a0b8

Browse files
ian-mijvoegele
authored andcommitted
Only include atom in connection error stat
Including the entire error reason tuple in the connection error can cause each connection error to create a new folsom statistic. To avoid this, only save the primary atom of the error reason in the statistic.
1 parent b8cfd20 commit 034a0b8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/riak_core_connection_mgr.erl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,11 @@ locate_endpoints({Type, Name}, Strategy, Locators) ->
584584
%% our book keeping for that endpoint. Black-list it, and
585585
%% adjust a backoff timer so that we wait a while before
586586
%% trying this endpoint again.
587+
588+
-spec fail_endpoint(ip_addr(), term(), proto_id(), #state{}) -> #state{}.
587589
fail_endpoint(Addr, Reason, ProtocolId, State) ->
588590
%% update the stats module
589-
Stat = {conn_error, Reason},
591+
Stat = {conn_error, reason_to_atom(Reason)},
590592
riak_core_connection_mgr_stats:update(Stat, Addr, ProtocolId),
591593
%% update the endpoint
592594
Fun = fun(EP=#ep{backoff_delay = Backoff, failures = Failures}) ->
@@ -600,6 +602,18 @@ fail_endpoint(Addr, Reason, ProtocolId, State) ->
600602
end,
601603
update_endpoint(Addr, Fun, State).
602604

605+
%% Attempt to extract atom from an error reason.
606+
607+
-spec reason_to_atom(term()) -> atom().
608+
reason_to_atom({{Err, _Val}, _Stack}) when is_atom(Err) ->
609+
Err;
610+
reason_to_atom({Err, _Stack}) when is_atom(Err) ->
611+
Err;
612+
reason_to_atom(Reason) when is_atom(Reason) ->
613+
Reason;
614+
reason_to_atom(_Reason) ->
615+
unknown_reason.
616+
603617
connect_endpoint(Addr, State) ->
604618
update_endpoint(Addr, fun(EP) ->
605619
EP#ep{is_black_listed = false,

0 commit comments

Comments
 (0)