diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_queue_consumers.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_variable_queue.erl | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/rabbit_queue_consumers.erl b/src/rabbit_queue_consumers.erl index 34e447ccd3..3ba9f89205 100644 --- a/src/rabbit_queue_consumers.erl +++ b/src/rabbit_queue_consumers.erl @@ -463,6 +463,8 @@ update_use({inactive, Since, Active, Avg}, active) -> Now = time_compat:monotonic_time(micro_seconds), {active, Now, use_avg(Active, Now - Since, Avg)}. +use_avg(0, 0, Avg) -> + Avg; use_avg(Active, Inactive, Avg) -> Time = Inactive + Active, rabbit_misc:moving_average(Time, ?USE_AVG_HALF_LIFE, Active / Time, Avg). diff --git a/src/rabbit_variable_queue.erl b/src/rabbit_variable_queue.erl index 99ea33b973..f66ba21605 100644 --- a/src/rabbit_variable_queue.erl +++ b/src/rabbit_variable_queue.erl @@ -809,7 +809,11 @@ update_rates(State = #vqstate{ in_counter = InCount, update_rate(Now, TS, Count, Rate) -> Time = time_compat:convert_time_unit(Now - TS, native, micro_seconds) / ?MICROS_PER_SECOND, - rabbit_misc:moving_average(Time, ?RATE_AVG_HALF_LIFE, Count / Time, Rate). + if + Time == 0 -> Rate; + true -> rabbit_misc:moving_average(Time, ?RATE_AVG_HALF_LIFE, + Count / Time, Rate) + end. ram_duration(State) -> State1 = #vqstate { rates = #rates { in = AvgIngressRate, |
