Merge pull request #6771 from DDDHuang/client_metrics

fix: client metrics count with qos
This commit is contained in:
DDDHuang 2022-01-19 09:27:30 +08:00 committed by GitHub
commit 8901a85398
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -858,6 +858,7 @@ inc_incoming_stats(Packet = ?PACKET(Type)) ->
case Type =:= ?PUBLISH of case Type =:= ?PUBLISH of
true -> true ->
inc_counter(recv_msg, 1), inc_counter(recv_msg, 1),
inc_qos_stats(recv_msg, Packet),
inc_counter(incoming_pubs, 1); inc_counter(incoming_pubs, 1);
false -> false ->
ok ok
@ -880,8 +881,9 @@ inc_outgoing_stats(Packet = ?PACKET(Type)) ->
end, end,
emqx_metrics:inc_sent(Packet). emqx_metrics:inc_sent(Packet).
inc_qos_stats(Type, #mqtt_packet{header = #mqtt_packet_header{qos = QoS}}) -> inc_qos_stats(Type, #mqtt_packet{header = #mqtt_packet_header{qos = QoS}}) when ?IS_QOS(QoS) ->
inc_counter(inc_qos_stats_key(Type, QoS), 1). inc_counter(inc_qos_stats_key(Type, QoS), 1);
inc_qos_stats(_, _) -> ok.
inc_qos_stats_key(send_msg, ?QOS_0) -> 'send_msg.qos0'; inc_qos_stats_key(send_msg, ?QOS_0) -> 'send_msg.qos0';
inc_qos_stats_key(send_msg, ?QOS_1) -> 'send_msg.qos1'; inc_qos_stats_key(send_msg, ?QOS_1) -> 'send_msg.qos1';