fix(connection): revert metric names for 'recv_msg.dropped.await_pubrel_timeout'

This commit is contained in:
Shawn 2022-02-09 15:41:28 +08:00
parent e220810b90
commit 9118cfb4ad
4 changed files with 67 additions and 59 deletions

View File

@ -124,35 +124,39 @@
-define(ACTIVE_N, 100).
-define(INFO_KEYS, [ socktype
, peername
, sockname
, sockstate
]).
-define(INFO_KEYS,
[ socktype
, peername
, sockname
, sockstate
]).
-define(CONN_STATS, [ recv_pkt
, recv_msg
, 'recv_msg.qos0'
, 'recv_msg.qos1'
, 'recv_msg.qos2'
, send_pkt
, send_msg
, 'send_msg.qos0'
, 'send_msg.qos1'
, 'send_msg.qos2'
, 'send_msg.dropped'
, 'send_msg.dropped.await_pubrel_timeout'
, 'send_msg.dropped.expired'
, 'send_msg.dropped.queue_full'
, 'send_msg.dropped.too_large'
]).
-define(CONN_STATS,
[ recv_pkt
, recv_msg
, 'recv_msg.qos0'
, 'recv_msg.qos1'
, 'recv_msg.qos2'
, 'recv_msg.dropped'
, 'recv_msg.dropped.await_pubrel_timeout'
, send_pkt
, send_msg
, 'send_msg.qos0'
, 'send_msg.qos1'
, 'send_msg.qos2'
, 'send_msg.dropped'
, 'send_msg.dropped.expired'
, 'send_msg.dropped.queue_full'
, 'send_msg.dropped.too_large'
]).
-define(SOCK_STATS, [ recv_oct
, recv_cnt
, send_oct
, send_cnt
, send_pend
]).
-define(SOCK_STATS,
[ recv_oct
, recv_cnt
, send_oct
, send_cnt
, send_pend
]).
-define(ENABLED(X), (X =/= undefined)).

View File

@ -147,27 +147,29 @@
-type(replies() :: list(publish() | pubrel())).
-define(INFO_KEYS, [id,
is_persistent,
subscriptions,
upgrade_qos,
retry_interval,
await_rel_timeout,
created_at
]).
-define(INFO_KEYS,
[ id
, is_persistent
, subscriptions
, upgrade_qos
, retry_interval
, await_rel_timeout
, created_at
]).
-define(STATS_KEYS, [subscriptions_cnt,
subscriptions_max,
inflight_cnt,
inflight_max,
mqueue_len,
mqueue_max,
mqueue_dropped,
next_pkt_id,
awaiting_rel_cnt,
awaiting_rel_max,
latency_stats
]).
-define(STATS_KEYS,
[ subscriptions_cnt
, subscriptions_max
, inflight_cnt
, inflight_max
, mqueue_len
, mqueue_max
, mqueue_dropped
, next_pkt_id
, awaiting_rel_cnt
, awaiting_rel_max
, latency_stats
]).
-define(DEFAULT_BATCH_N, 1000).
@ -730,8 +732,8 @@ inc_delivery_expired_cnt(N) ->
emqx_metrics:inc('delivery.dropped.expired', N).
inc_await_pubrel_timeout(N) ->
ok = inc_pd('send_msg.dropped', N),
ok = inc_pd('send_msg.dropped.await_pubrel_timeout', N),
ok = inc_pd('recv_msg.dropped', N),
ok = inc_pd('recv_msg.dropped.await_pubrel_timeout', N),
ok = emqx_metrics:inc('messages.dropped', N),
emqx_metrics:inc('messages.dropped.await_pubrel_timeout', N).

View File

@ -126,19 +126,19 @@ t_unsubscribe(_) ->
t_publish_qos0(_) ->
ok = meck:expect(emqx_broker, publish, fun(_) -> [] end),
Msg = emqx_message:make(clientid, ?QOS_0, <<"t">>, <<"payload">>),
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, Session = session()),
{ok, [], Session} = emqx_session:publish(clientinfo(), undefined, Msg, Session).
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, Session = session()),
{ok, [], Session} = emqx_session:publish(clientinfo(), undefined, Msg, Session).
t_publish_qos1(_) ->
ok = meck:expect(emqx_broker, publish, fun(_) -> [] end),
Msg = emqx_message:make(clientid, ?QOS_1, <<"t">>, <<"payload">>),
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, Session = session()),
{ok, [], Session} = emqx_session:publish(clientinfo(), 2, Msg, Session).
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, Session = session()),
{ok, [], Session} = emqx_session:publish(clientinfo(), 2, Msg, Session).
t_publish_qos2(_) ->
ok = meck:expect(emqx_broker, publish, fun(_) -> [] end),
Msg = emqx_message:make(clientid, ?QOS_2, <<"t">>, <<"payload">>),
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, session()),
{ok, [], Session} = emqx_session:publish(clientinfo(), 1, Msg, session()),
?assertEqual(1, emqx_session:info(awaiting_rel_cnt, Session)),
{ok, Session1} = emqx_session:pubrel(clientinfo(), 1, Session),
?assertEqual(0, emqx_session:info(awaiting_rel_cnt, Session1)),
@ -150,10 +150,10 @@ t_publish_qos2_with_error_return(_) ->
awaiting_rel => #{1 => ts(millisecond)}
}),
Msg = emqx_message:make(clientid, ?QOS_2, <<"t">>, <<"payload">>),
{error, ?RC_PACKET_IDENTIFIER_IN_USE} = emqx_session:publish(clientinfo(), 1, Msg, Session),
{ok, [], Session1} = emqx_session:publish(clientinfo(), 2, Msg, Session),
{error, ?RC_PACKET_IDENTIFIER_IN_USE} = emqx_session:publish(clientinfo(), 1, Msg, Session),
{ok, [], Session1} = emqx_session:publish(clientinfo(), 2, Msg, Session),
?assertEqual(2, emqx_session:info(awaiting_rel_cnt, Session1)),
{error, ?RC_RECEIVE_MAXIMUM_EXCEEDED} = emqx_session:publish(clientinfo(), 3, Msg, Session1).
{error, ?RC_RECEIVE_MAXIMUM_EXCEEDED} = emqx_session:publish(clientinfo(), 3, Msg, Session1).
t_is_awaiting_full_false(_) ->
Session = session(#{max_awaiting_rel => infinity}),

View File

@ -152,6 +152,10 @@ properties(client) ->
<<"Number of PUBLISH QoS1 packets received">>},
{'recv_msg.qos2', integer,
<<"Number of PUBLISH QoS2 packets received">>},
{'recv_msg.dropped', integer,
<<"Number of dropped PUBLISH messages">>},
{'recv_msg.dropped.await_pubrel_timeout', integer,
<<"Number of dropped PUBLISH messages due to waiting PUBREL timeout">>},
{recv_oct, integer,
<<"Number of bytes received by EMQ X Broker (the same below)">>},
{recv_pkt, integer,
@ -170,8 +174,6 @@ properties(client) ->
<<"Number of PUBLISH QoS2 messages sent">>},
{'send_msg.dropped', integer,
<<"Number of dropped PUBLISH messages">>},
{'send_msg.dropped.await_pubrel_timeout', integer,
<<"Number of dropped PUBLISH packets due to waiting PUBREL timeout">>},
{'send_msg.dropped.expired', integer,
<<"Number of dropped PUBLISH messages due to expired">>},
{'send_msg.dropped.queue_full', integer,