Skip to content

Commit

Permalink
Test the probe_interval config option
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Apr 23, 2024
1 parent 0f0dce2 commit a1c639f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
21 changes: 12 additions & 9 deletions test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ options("host_types") ->
{sm_backend, mnesia},
{component_backend, mnesia},
{s2s_backend, mnesia},
{instrumentation, #{}},
{instrumentation, default_config([instrumentation])},
{{s2s, <<"another host type">>}, default_s2s()},
{{s2s, <<"localhost">>}, default_s2s()},
{{s2s, <<"some host type">>}, default_s2s()},
Expand Down Expand Up @@ -93,9 +93,11 @@ options("miscellaneous") ->
id => "G-12345678",
secret => "Secret"
}}}},
{instrumentation, #{prometheus => #{},
exometer => #{all_metrics_are_global => true},
log => #{level => info}}},
{instrumentation, config([instrumentation],
#{probe_interval => 10,
prometheus => #{},
exometer => #{all_metrics_are_global => true},
log => #{level => info}})},
{{s2s, <<"anonymous.localhost">>}, default_s2s()},
{{s2s, <<"localhost">>}, default_s2s()},
{sm_backend, mnesia},
Expand Down Expand Up @@ -129,7 +131,7 @@ options("modules") ->
{sm_backend, mnesia},
{component_backend, mnesia},
{s2s_backend, mnesia},
{instrumentation, #{}},
{instrumentation, default_config([instrumentation])},
{{auth, <<"dummy_host">>}, default_auth()},
{{auth, <<"localhost">>}, default_auth()},
{{modules, <<"dummy_host">>}, all_modules()},
Expand Down Expand Up @@ -265,8 +267,7 @@ options("mongooseim-pgsql") ->
{sm_backend, mnesia},
{component_backend, mnesia},
{s2s_backend, mnesia},
{instrumentation, #{exometer => default_config([instrumentation, exometer]),
log => default_config([instrumentation, log])}},
{instrumentation, config([instrumentation], #{exometer => #{}, log => #{}})},
{{outgoing_pools, <<"anonymous.localhost">>},
[host_pool_config(
#{tag => special,
Expand Down Expand Up @@ -384,7 +385,7 @@ options("outgoing_pools") ->
{sm_backend, mnesia},
{component_backend, mnesia},
{s2s_backend, mnesia},
{instrumentation, #{}},
{instrumentation, default_config([instrumentation])},
{{auth, <<"anonymous.localhost">>}, default_auth()},
{{auth, <<"localhost">>}, default_auth()},
{{auth, <<"localhost.bis">>}, default_auth()},
Expand Down Expand Up @@ -412,7 +413,7 @@ options("s2s_only") ->
{sm_backend, mnesia},
{component_backend, mnesia},
{s2s_backend, mnesia},
{instrumentation, #{}},
{instrumentation, default_config([instrumentation])},
{{auth, <<"dummy_host">>}, default_auth()},
{{auth, <<"localhost">>}, default_auth()},
{{modules, <<"dummy_host">>}, #{}},
Expand Down Expand Up @@ -1102,6 +1103,8 @@ extra_service_listener_config() ->
conflict_behaviour => disconnect,
connection_type => component}.

default_config([instrumentation]) ->
#{probe_interval => 15};
default_config([instrumentation, log]) ->
#{level => debug};
default_config([instrumentation, exometer]) ->
Expand Down
8 changes: 5 additions & 3 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2934,10 +2934,12 @@ service_mongoose_system_metrics(_Config) ->
instrumentation(_Config) ->
P = [instrumentation],
T = fun(Opts) -> #{<<"instrumentation">> => Opts} end,
?cfg(P, #{}, T(#{})),
?cfg(P, #{prometheus => #{}}, T(#{<<"prometheus">> => #{}})),
?cfg(P, default_config(P), T(#{})),
?cfg(P ++ [prometheus], #{}, T(#{<<"prometheus">> => #{}})),
?cfg(P ++ [probe_interval], 10, T(#{<<"probe_interval">> => 10})),
?err(T(#{<<"prometheus">> => #{<<"fire">> => 1}})),
?err(T(#{<<"bad_module">> => #{}})).
?err(T(#{<<"bad_module">> => #{}})),
?err(T(#{<<"probe_interval">> => 0})).

instrumentation_log(_Config) ->
P = [instrumentation, log],
Expand Down
13 changes: 8 additions & 5 deletions test/config_parser_SUITE_data/miscellaneous.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,13 @@

[internal_databases.cets]

[instrumentation.prometheus]
[instrumentation]
probe_interval = 10

[instrumentation.exometer]
all_metrics_are_global = true
[instrumentation.prometheus]

[instrumentation.log]
level = "info"
[instrumentation.exometer]
all_metrics_are_global = true

[instrumentation.log]
level = "info"
2 changes: 1 addition & 1 deletion test/mongoose_config_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ minimal_config_opts() ->
{modules, <<"localhost">>} => #{},
{replaced_wait_timeout, <<"localhost">>} => 2000,
{s2s, <<"localhost">>} => config_parser_helper:default_s2s(),
instrumentation => #{}}.
instrumentation => config_parser_helper:default_config([instrumentation])}.

start_slave_node(Config) ->
SlaveNode = do_start_slave_node(),
Expand Down

0 comments on commit a1c639f

Please sign in to comment.