Skip to content

Commit

Permalink
Merge pull request #14 from Ubiquiti-Cloud/alf-add-reason-to-reschedu…
Browse files Browse the repository at this point in the history
…le-disconnectric

Add reason when disconnecting in the reconnect logic
  • Loading branch information
puzza007 committed Feb 17, 2015
2 parents 0969a7d + 35dd8d0 commit b625111
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/erlasticsearch_worker.erl
Expand Up @@ -109,8 +109,17 @@ handle_info(?SIGNAL_CONNECTION_REFRESH, #state
case do_request(RestRequest, Conn1) of
{{ok, _}, Conn2} ->
{some, Conn2};
{{error, _}, Conn2} ->
MetricReason = <<?WORKER_DISCONNECTED_METRIC/binary, <<"handle_info">>/binary>>,
{{error, Reason}, Conn2} ->
error_logger:error_msg("Erlasticsearch liveness check error: ~p", [Reason]),
ReasonBin =
case Reason of
{ErrorType, {Msg, _}} when ErrorType == call_error orelse
ErrorType == call_exception ->
atom_to_binary(Msg, latin1);
{connection_error, Msg} ->
atom_to_binary(Msg, latin1)
end,
MetricReason = <<?WORKER_DISCONNECTED_METRIC/binary, ReasonBin/binary>>,
quintana:notify_spiral({MetricReason, 1}),
_ = thrift_client:close(Conn2),
none
Expand Down

0 comments on commit b625111

Please sign in to comment.