diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-11-20 11:17:33 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-11-20 11:17:33 +0000 |
commit | 1e767b7b40f275dcdb95be447907464a14c50a15 (patch) | |
tree | 4106416bee0762904783196e01b61dc9b8fe5c45 | |
parent | c5a20827ed8b371d3261190f066e6c05574ccb90 (diff) | |
download | rabbitmq-server-bug25882.tar.gz |
Don't return consumer utilisation when idle or there are no consumers; no number can be particularly meaningful.bug25882
-rw-r--r-- | src/rabbit_amqqueue_process.erl | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index 80372fdb..65ab15c0 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1064,10 +1064,16 @@ i(messages, State) -> messages_unacknowledged]]); i(consumers, _) -> consumer_count(); -i(consumer_utilisation, #q{consumer_use = {active, Since, Avg}}) -> - consumer_use_avg(now_micros() - Since, 0, Avg); -i(consumer_utilisation, #q{consumer_use = {inactive, Since, Active, Avg}}) -> - consumer_use_avg(Active, now_micros() - Since, Avg); +i(consumer_utilisation, #q{consumer_use = ConsumerUse}) -> + case consumer_count() of + 0 -> ''; + _ -> case ConsumerUse of + {active, Since, Avg} -> + consumer_use_avg(now_micros() - Since, 0, Avg); + {inactive, Since, Active, Avg} -> + consumer_use_avg(Active, now_micros() - Since, Avg) + end + end; i(memory, _) -> {memory, M} = process_info(self(), memory), M; @@ -1107,7 +1113,10 @@ emit_stats(State) -> emit_stats(State, []). emit_stats(State, Extra) -> - rabbit_event:notify(queue_stats, Extra ++ infos(?STATISTICS_KEYS, State)). + ExtraKs = [K || {K, _} <- Extra], + Infos = [{K, V} || {K, V} <- infos(?STATISTICS_KEYS, State), + not lists:member(K, ExtraKs)], + rabbit_event:notify(queue_stats, Extra ++ Infos). emit_consumer_created(ChPid, CTag, Exclusive, AckRequired, QName, Args) -> rabbit_event:notify(consumer_created, @@ -1568,7 +1577,8 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, BQS3 = BQ:handle_pre_hibernate(BQS2), rabbit_event:if_enabled( State, #q.stats_timer, - fun () -> emit_stats(State, [{idle_since, now()}]) end), + fun () -> emit_stats(State, [{idle_since, now()}, + {consumer_utilisation, ''}]) end), State1 = rabbit_event:stop_stats_timer(State#q{backing_queue_state = BQS3}, #q.stats_timer), {hibernate, stop_rate_timer(State1)}. |