From b4c659fb54144e4911cda5fde4b63bad144c4c27 Mon Sep 17 00:00:00 2001 From: tigercl Date: Mon, 6 May 2019 19:17:54 +0800 Subject: [PATCH] Add suboptions for stats (#2507) --- src/emqx_stats.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/emqx_stats.erl b/src/emqx_stats.erl index bec56f142..771069704 100644 --- a/src/emqx_stats.erl +++ b/src/emqx_stats.erl @@ -73,6 +73,8 @@ -define(PUBSUB_STATS, [ 'topics/count', 'topics/max', + 'suboptions/count', + 'suboptions/max', 'subscribers/count', 'subscribers/max', 'subscriptions/count', @@ -242,9 +244,12 @@ code_change(_OldVsn, State, _Extra) -> %%------------------------------------------------------------------------------ safe_update_element(Key, Val) -> - try ets:update_element(?TAB, Key, {2, Val}) + try ets:update_element(?TAB, Key, {2, Val}) of + false -> + ets:insert_new(?TAB, {Key, Val}); + true -> + true catch error:badarg -> - ets:insert_new(?TAB, {Key, Val}) + ?LOG(warning, "[Stats] Update ~p to ~p failed", [Key, Val]) end. -