chore(statsd): update statsd conf root
This commit is contained in:
parent
61c11b8e3f
commit
4afae79be9
|
@ -72,7 +72,7 @@
|
|||
-export([ssl/1]).
|
||||
|
||||
%% will be used by emqx_ct_helper to find the dependent apps
|
||||
-export([includes/0]).
|
||||
-export([includes/0, extra_schema_fields/1]).
|
||||
|
||||
structs() -> ["cluster", "node", "rpc", "log",
|
||||
"zones", "listeners", "broker",
|
||||
|
@ -485,7 +485,7 @@ fields("alarm") ->
|
|||
];
|
||||
|
||||
fields(FieldName) ->
|
||||
extra_schema_fields(FieldName).
|
||||
?MODULE:extra_schema_fields(FieldName).
|
||||
|
||||
-ifndef(EMQX_EXT_SCHEMAS).
|
||||
%% Function extra_schema_fields/1 only terminates with explicit exception
|
||||
|
|
|
@ -46,6 +46,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
%create_default_app(),
|
||||
|
|
|
@ -32,6 +32,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
|
|
|
@ -35,6 +35,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
|
||||
|
|
|
@ -32,6 +32,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
|
|
|
@ -32,6 +32,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
|
|
|
@ -32,6 +32,7 @@ init_per_suite(Config) ->
|
|||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
## Statsd for EMQ X
|
||||
##--------------------------------------------------------------------
|
||||
|
||||
emqx_statsd:{
|
||||
statsd:{
|
||||
enable: true
|
||||
server: "127.0.0.1:8125"
|
||||
sample_time_interval: "10s"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
]},
|
||||
{env,[]},
|
||||
{modules, []},
|
||||
|
||||
{licenses, ["Apache 2.0"]},
|
||||
{links, []}
|
||||
]}.
|
||||
|
|
|
@ -84,23 +84,23 @@ statsd_api() ->
|
|||
[{"/statsd", Metadata, statsd}].
|
||||
|
||||
statsd(get, _Request) ->
|
||||
Response = emqx_config:get_raw([<<"emqx_statsd">>], #{}),
|
||||
Response = emqx_config:get_raw([<<"statsd">>], #{}),
|
||||
{200, Response};
|
||||
|
||||
statsd(put, Request) ->
|
||||
{ok, Body, _} = cowboy_req:read_body(Request),
|
||||
Params = emqx_json:decode(Body, [return_maps]),
|
||||
Enable = maps:get(<<"enable">>, Params),
|
||||
ok = emqx_config:update([emqx_statsd], Params),
|
||||
ok = emqx_config:update([statsd], Params),
|
||||
enable_statsd(Enable).
|
||||
|
||||
enable_statsd(true) ->
|
||||
ok = emqx_statsd_sup:stop_child(?APP),
|
||||
emqx_statsd_sup:start_child(?APP, emqx_config:get([?APP], #{})),
|
||||
emqx_statsd_sup:start_child(?APP, emqx_config:get([statsd], #{})),
|
||||
{200};
|
||||
enable_statsd(false) ->
|
||||
_ = emqx_statsd_sup:stop_child(?APP),
|
||||
{200}.
|
||||
|
||||
get_raw(Key, Def) ->
|
||||
emqx_config:get_raw([<<"emqx_statsd">>]++ [Key], Def).
|
||||
emqx_config:get_raw([<<"statsd">>]++ [Key], Def).
|
||||
|
|
|
@ -32,9 +32,9 @@ stop(_) ->
|
|||
ok.
|
||||
|
||||
maybe_enable_statsd() ->
|
||||
case emqx_config:get([?APP, enable], false) of
|
||||
case emqx_config:get([statsd, enable], false) of
|
||||
true ->
|
||||
emqx_statsd_sup:start_child(?APP, emqx_config:get([?APP], #{}));
|
||||
emqx_statsd_sup:start_child(?APP, emqx_config:get([statsd], #{}));
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
-typerefl_from_string({ip_port/0, emqx_statsd_schema, to_ip_port}).
|
||||
|
||||
structs() -> ["emqx_statsd"].
|
||||
structs() -> ["statsd"].
|
||||
|
||||
fields("emqx_statsd") ->
|
||||
fields("statsd") ->
|
||||
[ {enable, emqx_schema:t(boolean(), undefined, false)}
|
||||
, {server, fun server/1}
|
||||
, {sample_time_interval, fun duration_ms/1}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
%%
|
||||
[ {"emqx_data_bridge", emqx_data_bridge_schema}
|
||||
, {"emqx_retainer", emqx_retainer_schema}
|
||||
, {"emqx_statsd", emqx_statsd_schema}
|
||||
, {"emqx_authn", emqx_authn_schema}
|
||||
, {"emqx_authz", emqx_authz_schema}
|
||||
, {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema}
|
||||
|
@ -14,4 +13,5 @@
|
|||
, {"emqx_dashboard", emqx_dashboard_schema}
|
||||
, {"emqx_gateway", emqx_gateway_schema}
|
||||
, {"emqx_prometheus", emqx_prometheus_schema}
|
||||
, {"statsd", emqx_statsd_schema}
|
||||
].
|
||||
|
|
|
@ -152,6 +152,7 @@ prod_overrides() ->
|
|||
[{add, [ {erl_opts, [deterministic]}]}].
|
||||
|
||||
profiles() ->
|
||||
CommonCompileOpts = lists:keydelete('EMQX_EXT_SCHEMAS', 2, common_compile_opts()),
|
||||
Vsn = get_vsn(),
|
||||
[ {'emqx', [ {erl_opts, prod_compile_opts()}
|
||||
, {relx, relx(Vsn, cloud, bin)}
|
||||
|
@ -169,10 +170,10 @@ profiles() ->
|
|||
, {relx, relx(Vsn, edge, pkg)}
|
||||
, {overrides, prod_overrides()}
|
||||
]}
|
||||
, {check, [ {erl_opts, common_compile_opts()}
|
||||
, {check, [ {erl_opts, CommonCompileOpts}
|
||||
]}
|
||||
, {test, [ {deps, test_deps()}
|
||||
, {erl_opts, common_compile_opts() ++ erl_opts_i()}
|
||||
, {erl_opts, CommonCompileOpts ++ erl_opts_i() }
|
||||
, {extra_src_dirs, [{"test", [{recursive,true}]}]}
|
||||
]}
|
||||
] ++ ee_profiles(Vsn).
|
||||
|
|
Loading…
Reference in New Issue