Rename consumer_utilisation to consumer_capacity
Capacity is 100% when there are online consumers and no messages
This commit is contained in:
parent
b2b37f5626
commit
930c78795c
|
@ -110,6 +110,7 @@
|
|||
single_active_consumer_tag,
|
||||
consumers,
|
||||
consumer_utilisation,
|
||||
consumer_capacity,
|
||||
memory,
|
||||
slave_pids,
|
||||
synchronised_slave_pids,
|
||||
|
@ -1118,10 +1119,12 @@ i(messages, State) ->
|
|||
messages_unacknowledged]]);
|
||||
i(consumers, _) ->
|
||||
rabbit_queue_consumers:count();
|
||||
i(consumer_utilisation, #q{consumers = Consumers}) ->
|
||||
i(consumer_utilisation, State) ->
|
||||
i(consumer_capacity, State);
|
||||
i(consumer_capacity, #q{consumers = Consumers}) ->
|
||||
case rabbit_queue_consumers:count() of
|
||||
0 -> '';
|
||||
_ -> rabbit_queue_consumers:utilisation(Consumers)
|
||||
0 -> 0;
|
||||
_ -> rabbit_queue_consumers:capacity(Consumers)
|
||||
end;
|
||||
i(memory, _) ->
|
||||
{memory, M} = process_info(self(), memory),
|
||||
|
@ -1750,8 +1753,7 @@ handle_pre_hibernate(State = #q{backing_queue = BQ,
|
|||
State, #q.stats_timer,
|
||||
fun () -> emit_stats(State,
|
||||
[{idle_since,
|
||||
os:system_time(milli_seconds)},
|
||||
{consumer_utilisation, ''}])
|
||||
os:system_time(milli_seconds)}])
|
||||
end),
|
||||
State1 = rabbit_event:stop_stats_timer(State#q{backing_queue_state = BQS3},
|
||||
#q.stats_timer),
|
||||
|
|
|
@ -759,7 +759,7 @@ which_module(1) -> ?MODULE.
|
|||
|
||||
-record(aux_gc, {last_raft_idx = 0 :: ra:index()}).
|
||||
-record(aux, {name :: atom(),
|
||||
utilisation :: term(),
|
||||
capacity :: term(),
|
||||
gc = #aux_gc{} :: #aux_gc{}}).
|
||||
|
||||
init_aux(Name) when is_atom(Name) ->
|
||||
|
@ -769,7 +769,7 @@ init_aux(Name) when is_atom(Name) ->
|
|||
{write_concurrency, true}]),
|
||||
Now = erlang:monotonic_time(micro_seconds),
|
||||
#aux{name = Name,
|
||||
utilisation = {inactive, Now, 1, 1.0}}.
|
||||
capacity = {inactive, Now, 1, 1.0}}.
|
||||
|
||||
handle_aux(leader, _, garbage_collection, State, Log, _MacState) ->
|
||||
ra_log_wal:force_roll_over(ra_log_wal),
|
||||
|
@ -779,15 +779,15 @@ handle_aux(follower, _, garbage_collection, State, Log, MacState) ->
|
|||
{no_reply, force_eval_gc(Log, MacState, State), Log};
|
||||
handle_aux(_RaState, cast, eval, Aux0, Log, _MacState) ->
|
||||
{no_reply, Aux0, Log};
|
||||
handle_aux(_RaState, cast, Cmd, #aux{utilisation = Use0} = Aux0,
|
||||
handle_aux(_RaState, cast, Cmd, #aux{capacity = Use0} = Aux0,
|
||||
Log, _MacState)
|
||||
when Cmd == active orelse Cmd == inactive ->
|
||||
{no_reply, Aux0#aux{utilisation = update_use(Use0, Cmd)}, Log};
|
||||
{no_reply, Aux0#aux{capacity = update_use(Use0, Cmd)}, Log};
|
||||
handle_aux(_RaState, cast, tick, #aux{name = Name,
|
||||
utilisation = Use0} = State0,
|
||||
capacity = Use0} = State0,
|
||||
Log, MacState) ->
|
||||
true = ets:insert(rabbit_fifo_usage,
|
||||
{Name, utilisation(Use0)}),
|
||||
{Name, capacity(Use0)}),
|
||||
Aux = eval_gc(Log, MacState, State0),
|
||||
{no_reply, Aux, Log};
|
||||
handle_aux(_RaState, {call, _From}, {peek, Pos}, Aux0,
|
||||
|
@ -991,9 +991,11 @@ update_use({inactive, Since, Active, Avg}, active) ->
|
|||
Now = erlang:monotonic_time(micro_seconds),
|
||||
{active, Now, use_avg(Active, Now - Since, Avg)}.
|
||||
|
||||
utilisation({active, Since, Avg}) ->
|
||||
capacity({active, Since, Avg}) ->
|
||||
use_avg(erlang:monotonic_time(micro_seconds) - Since, 0, Avg);
|
||||
utilisation({inactive, Since, Active, Avg}) ->
|
||||
capacity({inactive, _, 1, 1.0}) ->
|
||||
1.0;
|
||||
capacity({inactive, Since, Active, Avg}) ->
|
||||
use_avg(Active, erlang:monotonic_time(micro_seconds) - Since, Avg).
|
||||
|
||||
use_avg(0, 0, Avg) ->
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
send_drained/0, deliver/5, record_ack/3, subtract_acks/3,
|
||||
possibly_unblock/3,
|
||||
resume_fun/0, notify_sent_fun/1, activate_limit_fun/0,
|
||||
credit/6, utilisation/1, is_same/3, get_consumer/1, get/3,
|
||||
credit/6, utilisation/1, capacity/1, is_same/3, get_consumer/1, get/3,
|
||||
consumer_tag/1, get_infos/1]).
|
||||
|
||||
%%----------------------------------------------------------------------------
|
||||
|
@ -409,10 +409,13 @@ drain_mode(true) -> drain;
|
|||
drain_mode(false) -> manual.
|
||||
|
||||
-spec utilisation(state()) -> ratio().
|
||||
utilisation(State) ->
|
||||
capacity(State).
|
||||
|
||||
utilisation(#state{use = {active, Since, Avg}}) ->
|
||||
-spec capacity(state()) -> ratio().
|
||||
capacity(#state{use = {active, Since, Avg}}) ->
|
||||
use_avg(erlang:monotonic_time(micro_seconds) - Since, 0, Avg);
|
||||
utilisation(#state{use = {inactive, Since, Active, Avg}}) ->
|
||||
capacity(#state{use = {inactive, Since, Active, Avg}}) ->
|
||||
use_avg(Active, erlang:monotonic_time(micro_seconds) - Since, Avg).
|
||||
|
||||
is_same(ChPid, ConsumerTag, {ChPid, #consumer{tag = ConsumerTag}}) ->
|
||||
|
|
|
@ -383,6 +383,7 @@ handle_tick(QName,
|
|||
_ -> rabbit_fifo:usage(Name)
|
||||
end,
|
||||
Infos = [{consumers, C},
|
||||
{consumer_capacity, Util},
|
||||
{consumer_utilisation, Util},
|
||||
{message_bytes_ready, MsgBytesReady},
|
||||
{message_bytes_unacknowledged, MsgBytesUnack},
|
||||
|
|
|
@ -71,7 +71,7 @@ var ALL_COLUMNS =
|
|||
['features_no_policy', 'Features (no policy)', false],
|
||||
['policy', 'Policy', false],
|
||||
['consumers', 'Consumer count', false],
|
||||
['consumer_utilisation', 'Consumer utilisation', false],
|
||||
['consumer_capacity', 'Consumer capacity', false],
|
||||
['state', 'State', true]],
|
||||
'Messages': [['msgs-ready', 'Ready', true],
|
||||
['msgs-unacked', 'Unacknowledged', true],
|
||||
|
@ -251,7 +251,7 @@ var HELP = {
|
|||
'queue-process-memory':
|
||||
'Total memory used by this queue process. This does not include in-memory message bodies (which may be shared between queues and will appear in the global "binaries" memory) but does include everything else.',
|
||||
|
||||
'queue-consumer-utilisation':
|
||||
'queue-consumer-capacity':
|
||||
'Fraction of the time that the queue is able to immediately deliver messages to consumers. If this number is less than 100% you may be able to deliver messages faster if: \
|
||||
<ul> \
|
||||
<li>There were more consumers or</li> \
|
||||
|
|
|
@ -133,8 +133,8 @@
|
|||
<td><%= fmt_string(queue.consumers) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Consumer utilisation <span class="help" id="queue-consumer-utilisation"></th>
|
||||
<td><%= fmt_percent(queue.consumer_utilisation) %></td>
|
||||
<th>Consumer capacity <span class="help" id="queue-consumer-capacity"></th>
|
||||
<td><%= fmt_percent(queue.consumer_capacity) %></td>
|
||||
</tr>
|
||||
<% if (is_quorum(queue) || is_stream(queue)) { %>
|
||||
<tr>
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
<% if (show_column('queues', 'consumers')) { %>
|
||||
<th><%= fmt_sort('Consumers', 'consumers') %></th>
|
||||
<% } %>
|
||||
<% if (show_column('queues', 'consumer_utilisation')) { %>
|
||||
<th><%= fmt_sort('Consumer utilisation', 'consumer_utilisation') %></th>
|
||||
<% if (show_column('queues', 'consumer_capacity')) { %>
|
||||
<th><%= fmt_sort('Consumer capacity', 'consumer_capacity') %></th>
|
||||
<% } %>
|
||||
<% if (show_column('queues', 'state')) { %>
|
||||
<th><%= fmt_sort('State', 'state') %></th>
|
||||
|
@ -157,8 +157,8 @@
|
|||
<% if (show_column('queues', 'consumers')) { %>
|
||||
<td class="c"><%= fmt_string(queue.consumers) %></td>
|
||||
<% } %>
|
||||
<% if (show_column('queues', 'consumer_utilisation')) { %>
|
||||
<td class="c"><%= fmt_percent(queue.consumer_utilisation) %></td>
|
||||
<% if (show_column('queues', 'consumer_capacity')) { %>
|
||||
<td class="c"><%= fmt_percent(queue.consumer_capacity) %></td>
|
||||
<% } %>
|
||||
<% if (show_column('queues', 'state')) { %>
|
||||
<td class="c"><%= fmt_object_state(queue) %></td>
|
||||
|
|
|
@ -2462,7 +2462,8 @@ format_output_test(Config) ->
|
|||
http_put(Config, "/queues/%2F/test0", QArgs, {group, '2xx'}),
|
||||
timer:sleep(2000),
|
||||
assert_list([#{name => <<"test0">>,
|
||||
consumer_utilisation => null,
|
||||
consumer_capacity => 0,
|
||||
consumer_utilisation => 0,
|
||||
exclusive_consumer_tag => null,
|
||||
recoverable_slaves => null}], http_get(Config, "/queues", ?OK)),
|
||||
http_delete(Config, "/queues/%2F/test0", {group, '2xx'}),
|
||||
|
|
Loading…
Reference in New Issue