Skip to content

Commit 7639b0a

Browse files
author
Daniil Fedotov
committed
Report queue reductions per second and GC options
1 parent b9d7e4d commit 7639b0a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/rabbit_amqqueue_process.erl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@
8686
%% that may or may not be still valid
8787
args_policy_version,
8888
%% running | flow | idle
89-
status
89+
status,
90+
%% process stats (reductions)
91+
stats
9092
}).
9193

9294
%%----------------------------------------------------------------------------
@@ -116,7 +118,9 @@
116118
slave_pids,
117119
synchronised_slave_pids,
118120
recoverable_slaves,
119-
state
121+
state,
122+
reductions,
123+
garbage_collection
120124
]).
121125

122126
-define(CREATION_EVENT_KEYS,
@@ -152,7 +156,8 @@ init_state(Q) ->
152156
senders = pmon:new(delegate),
153157
msg_id_to_channel = gb_trees:empty(),
154158
status = running,
155-
args_policy_version = 0},
159+
args_policy_version = 0,
160+
stats = rabbit_process_stats:init()},
156161
rabbit_event:init_stats_timer(State, #q.stats_timer).
157162

158163
init_it(Recover, From, State = #q{q = #amqqueue{exclusive_owner = none}}) ->
@@ -925,6 +930,11 @@ i(recoverable_slaves, #q{q = #amqqueue{name = Name,
925930
end;
926931
i(state, #q{status = running}) -> credit_flow:state();
927932
i(state, #q{status = State}) -> State;
933+
i(garbage_collection, _S) ->
934+
{garbage_collection, GC} = erlang:process_info(self(), garbage_collection),
935+
GC;
936+
i(reductions, #q{stats = Stats}) ->
937+
rabbit_process_stats:stat_rate_per_second(Stats, reductions);
928938
i(Item, #q{backing_queue_state = BQS, backing_queue = BQ}) ->
929939
BQ:info(Item, BQS).
930940

@@ -1303,10 +1313,11 @@ handle_info({drop_expired, _Vsn}, State) ->
13031313

13041314
handle_info(emit_stats, State) ->
13051315
emit_stats(State),
1316+
State1 = rabbit_process_stats:update(State),
13061317
%% Don't call noreply/1, we don't want to set timers
1307-
{State1, Timeout} = next_state(rabbit_event:reset_stats_timer(
1308-
State, #q.stats_timer)),
1309-
{noreply, State1, Timeout};
1318+
{State2, Timeout} = next_state(rabbit_event:reset_stats_timer(
1319+
State1, #q.stats_timer)),
1320+
{noreply, State2, Timeout};
13101321

13111322
handle_info({'DOWN', _MonitorRef, process, DownPid, _Reason},
13121323
State = #q{q = #amqqueue{exclusive_owner = DownPid}}) ->

0 commit comments

Comments
 (0)