diff --git a/src/emqx_connection.erl b/src/emqx_connection.erl index abba2bcdd..ccf4430a9 100644 --- a/src/emqx_connection.erl +++ b/src/emqx_connection.erl @@ -881,8 +881,9 @@ inc_outgoing_stats(Packet = ?PACKET(Type)) -> end, emqx_metrics:inc_sent(Packet). -inc_qos_stats(Type, #mqtt_packet{header = #mqtt_packet_header{qos = QoS}}) -> - inc_counter(inc_qos_stats_key(Type, QoS), 1). +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_qos_stats(_, _) -> ok. inc_qos_stats_key(send_msg, ?QOS_0) -> 'send_msg.qos0'; inc_qos_stats_key(send_msg, ?QOS_1) -> 'send_msg.qos1';