chore: emqx_dashboard_monitor:current_rate/0 not exported anymore
This commit is contained in:
parent
a35698009c
commit
3d6b65aced
|
@ -40,11 +40,14 @@
|
||||||
-export([
|
-export([
|
||||||
samplers/0,
|
samplers/0,
|
||||||
samplers/2,
|
samplers/2,
|
||||||
current_rate/0,
|
|
||||||
current_rate/1,
|
current_rate/1,
|
||||||
granularity_adapter/1
|
granularity_adapter/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
-ifdef(TEST).
|
||||||
|
-export([current_rate_cluster/0]).
|
||||||
|
-endif.
|
||||||
|
|
||||||
%% for rpc
|
%% for rpc
|
||||||
-export([do_sample/2]).
|
-export([do_sample/2]).
|
||||||
|
|
||||||
|
@ -112,8 +115,33 @@ granularity_adapter(List) when length(List) > 1000 ->
|
||||||
granularity_adapter(List) ->
|
granularity_adapter(List) ->
|
||||||
List.
|
List.
|
||||||
|
|
||||||
|
current_rate(all) ->
|
||||||
|
current_rate_cluster();
|
||||||
|
current_rate(Node) when Node == node() ->
|
||||||
|
try
|
||||||
|
{ok, Rate} = do_call(current_rate),
|
||||||
|
{ok, Rate}
|
||||||
|
catch
|
||||||
|
_E:R ->
|
||||||
|
?SLOG(warning, #{msg => "dashboard_monitor_error", reason => R}),
|
||||||
|
%% Rate map 0, ensure api will not crash.
|
||||||
|
%% When joining cluster, dashboard monitor restart.
|
||||||
|
Rate0 = [
|
||||||
|
{Key, 0}
|
||||||
|
|| Key <- ?GAUGE_SAMPLER_LIST ++ maps:values(?DELTA_SAMPLER_RATE_MAP)
|
||||||
|
],
|
||||||
|
{ok, maps:merge(maps:from_list(Rate0), non_rate_value())}
|
||||||
|
end;
|
||||||
|
current_rate(Node) ->
|
||||||
|
case emqx_dashboard_proto_v1:current_rate(Node) of
|
||||||
|
{badrpc, Reason} ->
|
||||||
|
{badrpc, {Node, Reason}};
|
||||||
|
{ok, Rate} ->
|
||||||
|
{ok, Rate}
|
||||||
|
end.
|
||||||
|
|
||||||
%% Get the current rate. Not the current sampler data.
|
%% Get the current rate. Not the current sampler data.
|
||||||
current_rate() ->
|
current_rate_cluster() ->
|
||||||
Fun =
|
Fun =
|
||||||
fun
|
fun
|
||||||
(Node, Cluster) when is_map(Cluster) ->
|
(Node, Cluster) when is_map(Cluster) ->
|
||||||
|
@ -133,31 +161,6 @@ current_rate() ->
|
||||||
{ok, Rate}
|
{ok, Rate}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
current_rate(all) ->
|
|
||||||
current_rate();
|
|
||||||
current_rate(Node) when Node == node() ->
|
|
||||||
try
|
|
||||||
{ok, Rate} = do_call(current_rate),
|
|
||||||
{ok, Rate}
|
|
||||||
catch
|
|
||||||
_E:R ->
|
|
||||||
?SLOG(warning, #{msg => "dashboard_monitor_error", reason => R}),
|
|
||||||
%% Rate map 0, ensure api will not crash.
|
|
||||||
%% When joining cluster, dashboard monitor restart.
|
|
||||||
Rate0 = [
|
|
||||||
{Key, 0}
|
|
||||||
|| Key <- ?GAUGE_SAMPLER_LIST ++ maps:values(?DELTA_SAMPLER_RATE_MAP)
|
|
||||||
],
|
|
||||||
{ok, maps:from_list(Rate0)}
|
|
||||||
end;
|
|
||||||
current_rate(Node) ->
|
|
||||||
case emqx_dashboard_proto_v1:current_rate(Node) of
|
|
||||||
{badrpc, Reason} ->
|
|
||||||
{badrpc, {Node, Reason}};
|
|
||||||
{ok, Rate} ->
|
|
||||||
{ok, Rate}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% -------------------------------------------------------------------------------------------------
|
%% -------------------------------------------------------------------------------------------------
|
||||||
%% gen_server functions
|
%% gen_server functions
|
||||||
|
|
||||||
|
@ -258,8 +261,13 @@ merge_cluster_sampler_map(M1, M2) ->
|
||||||
merge_cluster_rate(Node, Cluster) ->
|
merge_cluster_rate(Node, Cluster) ->
|
||||||
Fun =
|
Fun =
|
||||||
fun
|
fun
|
||||||
(topics, Value, NCluster) ->
|
%% cluster-synced values
|
||||||
NCluster#{topics => Value};
|
(topics, V, NCluster) ->
|
||||||
|
NCluster#{topics => V};
|
||||||
|
(retained_msg_count, V, NCluster) ->
|
||||||
|
NCluster#{retained_msg_count => V};
|
||||||
|
(license_quota, V, NCluster) ->
|
||||||
|
NCluster#{license_quota => V};
|
||||||
(Key, Value, NCluster) ->
|
(Key, Value, NCluster) ->
|
||||||
ClusterValue = maps:get(Key, NCluster, 0),
|
ClusterValue = maps:get(Key, NCluster, 0),
|
||||||
NCluster#{Key => Value + ClusterValue}
|
NCluster#{Key => Value + ClusterValue}
|
||||||
|
|
|
@ -151,7 +151,11 @@ monitor_current(get, #{bindings := Bindings}) ->
|
||||||
RawNode = maps:get(node, Bindings, <<"all">>),
|
RawNode = maps:get(node, Bindings, <<"all">>),
|
||||||
emqx_utils_api:with_node_or_cluster(RawNode, fun current_rate/1).
|
emqx_utils_api:with_node_or_cluster(RawNode, fun current_rate/1).
|
||||||
|
|
||||||
|
-spec current_rate(atom()) ->
|
||||||
|
{error, term()}
|
||||||
|
| {ok, Result :: map()}.
|
||||||
current_rate(Node) ->
|
current_rate(Node) ->
|
||||||
|
%% Node :: 'all' or `NodeName`
|
||||||
case emqx_dashboard_monitor:current_rate(Node) of
|
case emqx_dashboard_monitor:current_rate(Node) of
|
||||||
{badrpc, _} = BadRpc ->
|
{badrpc, _} = BadRpc ->
|
||||||
{error, BadRpc};
|
{error, BadRpc};
|
||||||
|
|
Loading…
Reference in New Issue