Add suboptions for stats (#2507)

This commit is contained in:
tigercl 2019-05-06 19:17:54 +08:00 committed by JianBo He
parent 0ea6697a57
commit b4c659fb54
1 changed files with 8 additions and 3 deletions

View File

@ -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.