Do not emit stats if connection has not been stablished
Ensures stats are not emitted until the connection is stablished. A non-pid value crashes the stats gc. rabbitmq-management-agent#42
This commit is contained in:
parent
2da7008647
commit
f124727c3b
|
|
@ -186,6 +186,11 @@ maybe_emit_stats(State) ->
|
|||
rabbit_event:if_enabled(State, #state.stats_timer,
|
||||
fun() -> emit_stats(State) end).
|
||||
|
||||
emit_stats(State=#state{connection = C}) when C == none; C == undefined ->
|
||||
%% Avoid emitting stats on terminate when the connection has not yet been
|
||||
%% established, as this causes orphan entries on the stats database
|
||||
State1 = rabbit_event:reset_stats_timer(State, #state.stats_timer),
|
||||
State1;
|
||||
emit_stats(State=#state{socket=Sock, connection=Conn}) ->
|
||||
SockInfos = case rabbit_net:getstat(Sock,
|
||||
[recv_oct, recv_cnt, send_oct, send_cnt, send_pend]) of
|
||||
|
|
|
|||
Loading…
Reference in New Issue