update external stats on init

This commit is contained in:
kjnilsson 2016-09-07 12:50:05 +01:00
parent d08fef8f35
commit 3ac9591a43
2 changed files with 10 additions and 11 deletions

View File

@ -329,14 +329,9 @@ init([]) ->
State = #state{fd_total = file_handle_cache:ulimit(),
fhc_stats = file_handle_cache_stats:get(),
node_owners = sets:new()},
%% If we emit an update straight away we will do so just before
%% the mgmt db starts up - and then have to wait ?REFRESH_RATIO
%% until we send another. So let's have a shorter wait in the hope
%% that the db will have started by the time we emit an update,
%% and thus shorten that little gap at startup where mgmt knows
%% nothing about any nodes.
erlang:send_after(1000, self(), emit_update),
{ok, State}.
%% We can update stats straight away as they need to be available
%% when the mgmt plugin starts a collector
{ok, emit_update(State)}.
handle_call(_Req, _From, State) ->
{reply, unknown_request, State}.

View File

@ -79,10 +79,14 @@ read_table_rpc(Config, Table) ->
read_table(Table) ->
ets:tab2list(Table).
force_stats() ->
rabbit_mgmt_external_stats ! emit_update.
node(Config) ->
timer:sleep(2000),
[_] = read_table_rpc(Config, node_persister_metrics),
[_] = read_table_rpc(Config, node_coarse_metrics),
[_, _] = read_table_rpc(Config, node_node_metrics),
[_] = read_table_rpc(Config, node_metrics).
[_] = read_table_rpc(Config, node_metrics),
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, force_stats, []),
timer:sleep(100),
[_, _, _] = read_table_rpc(Config, node_node_metrics). % 3 nodes as ct adds one