summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordcorbacho <dparracorbacho@piotal.io>2021-02-24 16:20:52 +0100
committerdcorbacho <dparracorbacho@piotal.io>2021-02-24 16:20:52 +0100
commit930c78795cdbfa0dc84f4bbab2655b024743a594 (patch)
tree5b56e83cd25ffdb0132db0db781d831cd8470f96
parentb2b37f5626661a180c1196c83a95d4d933dbbe35 (diff)
downloadrabbitmq-server-git-930c78795cdbfa0dc84f4bbab2655b024743a594.tar.gz
Rename consumer_utilisation to consumer_capacity
Capacity is 100% when there are online consumers and no messages
-rw-r--r--deps/rabbit/src/rabbit_amqqueue_process.erl12
-rw-r--r--deps/rabbit/src/rabbit_fifo.erl18
-rw-r--r--deps/rabbit/src/rabbit_queue_consumers.erl9
-rw-r--r--deps/rabbit/src/rabbit_quorum_queue.erl1
-rw-r--r--deps/rabbitmq_management/priv/www/js/global.js4
-rw-r--r--deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs4
-rw-r--r--deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs8
-rw-r--r--deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl3
8 files changed, 34 insertions, 25 deletions
diff --git a/deps/rabbit/src/rabbit_amqqueue_process.erl b/deps/rabbit/src/rabbit_amqqueue_process.erl
index 727c41542f..6f21eb1be1 100644
--- a/deps/rabbit/src/rabbit_amqqueue_process.erl
+++ b/deps/rabbit/src/rabbit_amqqueue_process.erl
@@ -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),
diff --git a/deps/rabbit/src/rabbit_fifo.erl b/deps/rabbit/src/rabbit_fifo.erl
index 3b5b9f5e40..e2f69d047b 100644
--- a/deps/rabbit/src/rabbit_fifo.erl
+++ b/deps/rabbit/src/rabbit_fifo.erl
@@ -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) ->
diff --git a/deps/rabbit/src/rabbit_queue_consumers.erl b/deps/rabbit/src/rabbit_queue_consumers.erl
index 5046aea42c..c5a62ea677 100644
--- a/deps/rabbit/src/rabbit_queue_consumers.erl
+++ b/deps/rabbit/src/rabbit_queue_consumers.erl
@@ -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}}) ->
diff --git a/deps/rabbit/src/rabbit_quorum_queue.erl b/deps/rabbit/src/rabbit_quorum_queue.erl
index 3fb3e026d4..52b9930ab6 100644
--- a/deps/rabbit/src/rabbit_quorum_queue.erl
+++ b/deps/rabbit/src/rabbit_quorum_queue.erl
@@ -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},
diff --git a/deps/rabbitmq_management/priv/www/js/global.js b/deps/rabbitmq_management/priv/www/js/global.js
index fbd1b5e33c..9f48189672 100644
--- a/deps/rabbitmq_management/priv/www/js/global.js
+++ b/deps/rabbitmq_management/priv/www/js/global.js
@@ -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> \
diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs
index 27297b3757..465808da8f 100644
--- a/deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs
+++ b/deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs
@@ -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>
diff --git a/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs b/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs
index 6e13f84361..cc9ce8f009 100644
--- a/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs
+++ b/deps/rabbitmq_management/priv/www/js/tmpl/queues.ejs
@@ -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>
diff --git a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl
index 1dc00d2e12..59dddbed2a 100644
--- a/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl
+++ b/deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl
@@ -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'}),