@@ -1285,6 +1285,7 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
1285
1285
confirm_enabled = ConfirmEnabled ,
1286
1286
delivery_flow = Flow
1287
1287
}) ->
1288
+ rabbit_global_counters :messages_received (all , 1 ),
1288
1289
check_msg_size (Content , MaxMessageSize , GCThreshold ),
1289
1290
ExchangeName = rabbit_misc :r (VHostPath , exchange , ExchangeNameBin ),
1290
1291
check_write_permitted (ExchangeName , User , AuthzContext ),
@@ -1302,7 +1303,8 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
1302
1303
{MsgSeqNo , State1 } =
1303
1304
case DoConfirm orelse Mandatory of
1304
1305
false -> {undefined , State };
1305
- true -> SeqNo = State # ch .publish_seqno ,
1306
+ true -> rabbit_global_counters :messages_received_confirm (all , 1 ),
1307
+ SeqNo = State # ch .publish_seqno ,
1306
1308
{SeqNo , State # ch {publish_seqno = SeqNo + 1 }}
1307
1309
end ,
1308
1310
case rabbit_basic :message (ExchangeName , RoutingKey , DecodedContent ) of
@@ -1314,9 +1316,11 @@ handle_method(#'basic.publish'{exchange = ExchangeNameBin,
1314
1316
Username , TraceState ),
1315
1317
DQ = {Delivery # delivery {flow = Flow }, QNames },
1316
1318
{noreply , case Tx of
1317
- none -> deliver_to_queues (DQ , State1 );
1318
- {Msgs , Acks } -> Msgs1 = ? QUEUE :in (DQ , Msgs ),
1319
- State1 # ch {tx = {Msgs1 , Acks }}
1319
+ none ->
1320
+ deliver_to_queues (DQ , State1 );
1321
+ {Msgs , Acks } ->
1322
+ Msgs1 = ? QUEUE :in (DQ , Msgs ),
1323
+ State1 # ch {tx = {Msgs1 , Acks }}
1320
1324
end };
1321
1325
{error , Reason } ->
1322
1326
precondition_failed (" invalid message: ~p " , [Reason ])
@@ -1363,11 +1367,9 @@ handle_method(#'basic.get'{queue = QueueNameBin, no_ack = NoAck},
1363
1367
handle_basic_get (WriterPid , DeliveryTag , NoAck , MessageCount , Msg ,
1364
1368
State # ch {queue_states = QueueStates });
1365
1369
{empty , QueueStates } ->
1370
+ rabbit_global_counters :messages_get_empty (all , 1 ),
1366
1371
? INCR_STATS (queue_stats , QueueName , 1 , get_empty , State ),
1367
1372
{reply , # 'basic.get_empty' {}, State # ch {queue_states = QueueStates }};
1368
- empty ->
1369
- ? INCR_STATS (queue_stats , QueueName , 1 , get_empty , State ),
1370
- {reply , # 'basic.get_empty' {}, State };
1371
1373
{error , {unsupported , single_active_consumer }} ->
1372
1374
rabbit_misc :protocol_error (
1373
1375
resource_locked ,
@@ -1692,9 +1694,9 @@ handle_method(#'tx.select'{}, _, State) ->
1692
1694
handle_method (# 'tx.commit' {}, _ , # ch {tx = none }) ->
1693
1695
precondition_failed (" channel is not transactional" );
1694
1696
1695
- handle_method (# 'tx.commit' {}, _ , State = # ch {tx = {Msgs , Acks },
1697
+ handle_method (# 'tx.commit' {}, _ , State = # ch {tx = {Deliveries , Acks },
1696
1698
limiter = Limiter }) ->
1697
- State1 = queue_fold (fun deliver_to_queues /2 , State , Msgs ),
1699
+ State1 = queue_fold (fun deliver_to_queues /2 , State , Deliveries ),
1698
1700
Rev = fun (X ) -> lists :reverse (lists :sort (X )) end ,
1699
1701
{State2 , Actions2 } =
1700
1702
lists :foldl (fun ({ack , A }, {Acc , Actions }) ->
@@ -1964,15 +1966,28 @@ record_sent(Type, Tag, AckRequired,
1964
1966
unacked_message_q = UAMQ ,
1965
1967
next_tag = DeliveryTag
1966
1968
}) ->
1967
- ? INCR_STATS (queue_stats , QName , 1 , case {Type , AckRequired } of
1968
- {get , true } -> get ;
1969
- {get , false } -> get_no_ack ;
1970
- {deliver , true } -> deliver ;
1971
- {deliver , false } -> deliver_no_ack
1972
- end , State ),
1969
+ rabbit_global_counters :messages_delivered (all , 1 ),
1970
+ ? INCR_STATS (queue_stats , QName , 1 ,
1971
+ case {Type , AckRequired } of
1972
+ {get , true } ->
1973
+ rabbit_global_counters :messages_delivered_get_manual_ack (all , 1 ),
1974
+ get ;
1975
+ {get , false } ->
1976
+ rabbit_global_counters :messages_delivered_get_auto_ack (all , 1 ),
1977
+ get_no_ack ;
1978
+ {deliver , true } ->
1979
+ rabbit_global_counters :messages_delivered_consume_manual_ack (all , 1 ),
1980
+ deliver ;
1981
+ {deliver , false } ->
1982
+ rabbit_global_counters :messages_delivered_consume_auto_ack (all , 1 ),
1983
+ deliver_no_ack
1984
+ end , State ),
1973
1985
case Redelivered of
1974
- true -> ? INCR_STATS (queue_stats , QName , 1 , redeliver , State );
1975
- false -> ok
1986
+ true ->
1987
+ rabbit_global_counters :messages_redelivered (all , 1 ),
1988
+ ? INCR_STATS (queue_stats , QName , 1 , redeliver , State );
1989
+ false ->
1990
+ ok
1976
1991
end ,
1977
1992
DeliveredAt = os :system_time (millisecond ),
1978
1993
rabbit_trace :tap_out (Msg , ConnName , ChannelNum , Username , TraceState ),
@@ -2036,6 +2051,7 @@ ack(Acked, State = #ch{queue_states = QueueStates0}) ->
2036
2051
2037
2052
incr_queue_stats (QName , MsgIds , State ) ->
2038
2053
Count = length (MsgIds ),
2054
+ rabbit_global_counters :messages_acknowledged (all , Count ),
2039
2055
? INCR_STATS (queue_stats , QName , Count , ack , State ).
2040
2056
2041
2057
% % {Msgs, Acks}
@@ -2110,6 +2126,7 @@ deliver_to_queues({#delivery{message = #basic_message{exchange_name = XName},
2110
2126
mandatory = false },
2111
2127
_RoutedToQueueNames = []}, State ) -> % % optimisation
2112
2128
? INCR_STATS (exchange_stats , XName , 1 , publish , State ),
2129
+ rabbit_global_counters :messages_unroutable_dropped (all , 1 ),
2113
2130
? INCR_STATS (exchange_stats , XName , 1 , drop_unroutable , State ),
2114
2131
State ;
2115
2132
deliver_to_queues ({Delivery = # delivery {message = Message = # basic_message {exchange_name = XName },
@@ -2128,6 +2145,7 @@ deliver_to_queues({Delivery = #delivery{message = Message = #basic_message{ex
2128
2145
Qs = rabbit_amqqueue :lookup (AllNames ),
2129
2146
case rabbit_queue_type :deliver (Qs , Delivery , QueueStates0 ) of
2130
2147
{ok , QueueStates , Actions } ->
2148
+ rabbit_global_counters :messages_routed (all , length (Qs )),
2131
2149
% % NB: the order here is important since basic.returns must be
2132
2150
% % sent before confirms.
2133
2151
ok = process_routing_mandatory (Mandatory , Qs , Message , State0 ),
@@ -2164,6 +2182,7 @@ deliver_to_queues({Delivery = #delivery{message = Message = #basic_message{ex
2164
2182
end ,
2165
2183
case rabbit_queue_type :deliver (Qs , Delivery , QueueStates0 ) of
2166
2184
{ok , QueueStates , Actions } ->
2185
+ rabbit_global_counters :messages_routed (all , length (Qs )),
2167
2186
% % NB: the order here is important since basic.returns must be
2168
2187
% % sent before confirms.
2169
2188
ok = process_routing_mandatory (Mandatory , Qs , Message , State0 ),
@@ -2213,11 +2232,13 @@ infer_extra_bcc(Qs) ->
2213
2232
process_routing_mandatory (_Mandatory = true ,
2214
2233
_RoutedToQs = [],
2215
2234
Msg , State ) ->
2235
+ rabbit_global_counters :messages_unroutable_returned (all , 1 ),
2216
2236
ok = basic_return (Msg , State , no_route ),
2217
2237
ok ;
2218
2238
process_routing_mandatory (_Mandatory = false ,
2219
2239
_RoutedToQs = [],
2220
2240
# basic_message {exchange_name = ExchangeName }, State ) ->
2241
+ rabbit_global_counters :messages_unroutable_dropped (all , 1 ),
2221
2242
? INCR_STATS (exchange_stats , ExchangeName , 1 , drop_unroutable , State ),
2222
2243
ok ;
2223
2244
process_routing_mandatory (_ , _ , _ , _ ) ->
@@ -2245,6 +2266,7 @@ send_confirms_and_nacks(State = #ch{tx = none, confirmed = C, rejected = R}) ->
2245
2266
case rabbit_node_monitor :pause_partition_guard () of
2246
2267
ok ->
2247
2268
Confirms = lists :append (C ),
2269
+ rabbit_global_counters :messages_confirmed (all , length (Confirms )),
2248
2270
Rejects = lists :append (R ),
2249
2271
ConfirmMsgSeqNos =
2250
2272
lists :foldl (
@@ -2783,10 +2805,10 @@ get_operation_timeout_and_deadline() ->
2783
2805
Deadline = now_millis () + Timeout ,
2784
2806
{Timeout , Deadline }.
2785
2807
2786
- queue_fold (Fun , Init , Q ) ->
2787
- case ? QUEUE :out (Q ) of
2788
- {empty , _Q } -> Init ;
2789
- {{value , V }, Q1 } -> queue_fold (Fun , Fun (V , Init ), Q1 )
2808
+ queue_fold (Fun , Acc , Queue ) ->
2809
+ case ? QUEUE :out (Queue ) of
2810
+ {empty , _Queue } -> Acc ;
2811
+ {{value , Item }, Queue1 } -> queue_fold (Fun , Fun (Item , Acc ), Queue1 )
2790
2812
end .
2791
2813
2792
2814
evaluate_consumer_timeout (State0 = # ch {cfg = # conf {channel = Channel ,
0 commit comments