Procházet zdrojové kódy

feat: hidden stats config

某文 před 3 roky
rodič
revize
e5b85916b6

+ 6 - 7
apps/emqx/src/emqx_schema.erl

@@ -204,7 +204,9 @@ roots(low) ->
         {"stats",
         {"stats",
             sc(
             sc(
                 ref("stats"),
                 ref("stats"),
-                #{}
+                #{
+                    importance => ?IMPORTANCE_HIDDEN
+                }
             )},
             )},
         {"sysmon",
         {"sysmon",
             sc(
             sc(
@@ -339,6 +341,7 @@ fields("stats") ->
                 boolean(),
                 boolean(),
                 #{
                 #{
                     default => true,
                     default => true,
+                    importance => ?IMPORTANCE_HIDDEN,
                     desc => ?DESC(stats_enable)
                     desc => ?DESC(stats_enable)
                 }
                 }
             )}
             )}
@@ -609,8 +612,7 @@ fields("mqtt") ->
             )}
             )}
     ];
     ];
 fields("zone") ->
 fields("zone") ->
-    Fields = emqx_zone_schema:roots(),
-    [{F, ref(emqx_zone_schema, F)} || F <- Fields];
+    emqx_zone_schema:zone();
 fields("flapping_detect") ->
 fields("flapping_detect") ->
     [
     [
         {"enable",
         {"enable",
@@ -1971,10 +1973,7 @@ desc("persistent_session_builtin") ->
 desc("persistent_table_mria_opts") ->
 desc("persistent_table_mria_opts") ->
     "Tuning options for the mria table.";
     "Tuning options for the mria table.";
 desc("stats") ->
 desc("stats") ->
-    "Enable/disable statistic data collection.\n"
-    "Statistic data such as message receive/send count/rate etc. "
-    "It provides insights of system performance and helps to diagnose issues. "
-    "You can find statistic data from the dashboard, or from the '/stats' API.";
+    "deprecated since 5.0.23";
 desc("authorization") ->
 desc("authorization") ->
     "Settings for client authorization.";
     "Settings for client authorization.";
 desc("mqtt") ->
 desc("mqtt") ->

+ 26 - 1
apps/emqx/src/emqx_zone_schema.erl

@@ -15,8 +15,10 @@
 %%--------------------------------------------------------------------
 %%--------------------------------------------------------------------
 
 
 -module(emqx_zone_schema).
 -module(emqx_zone_schema).
+-include_lib("typerefl/include/types.hrl").
+-include_lib("hocon/include/hoconsc.hrl").
 
 
--export([namespace/0, roots/0, fields/1, desc/1]).
+-export([namespace/0, roots/0, fields/1, desc/1, zone/0, zone_without_hidden/0]).
 
 
 namespace() -> zone.
 namespace() -> zone.
 
 
@@ -33,6 +35,29 @@ roots() ->
         "overload_protection"
         "overload_protection"
     ].
     ].
 
 
+zone() ->
+    Fields = roots(),
+    Hidden = hidden(),
+    lists:map(
+        fun(F) ->
+            case lists:member(F, Hidden) of
+                true ->
+                    {F, ?HOCON(?R_REF(F), #{importance => ?IMPORTANCE_HIDDEN})};
+                false ->
+                    {F, ?HOCON(?R_REF(F), #{})}
+            end
+        end,
+        Fields
+    ).
+
+zone_without_hidden() ->
+    lists:map(fun(F) -> {F, ?HOCON(?R_REF(F), #{})} end, roots() -- hidden()).
+
+hidden() ->
+    [
+        "stats"
+    ].
+
 %% zone schemas are clones from the same name from root level
 %% zone schemas are clones from the same name from root level
 %% only not allowed to have default values.
 %% only not allowed to have default values.
 fields(Name) ->
 fields(Name) ->

+ 2 - 3
apps/emqx_management/src/emqx_mgmt_api_configs.erl

@@ -352,8 +352,7 @@ with_default_value(Type, Value) ->
     Type#{example => emqx_map_lib:binary_string(Value)}.
     Type#{example => emqx_map_lib:binary_string(Value)}.
 
 
 global_zone_roots() ->
 global_zone_roots() ->
-    lists:map(fun({K, _}) -> K end, global_zone_schema()).
+    lists:map(fun({K, _}) -> list_to_binary(K) end, global_zone_schema()).
 
 
 global_zone_schema() ->
 global_zone_schema() ->
-    Roots = hocon_schema:roots(emqx_zone_schema),
-    lists:map(fun({RootKey, {_Root, Schema}}) -> {RootKey, Schema} end, Roots).
+    emqx_zone_schema:zone_without_hidden().