From 24f397f9748812f87a889a0c8f1e773b1bc715e5 Mon Sep 17 00:00:00 2001 From: Janusz Jakubiec Date: Fri, 11 Oct 2024 17:48:52 +0200 Subject: [PATCH 1/2] Updating documentation --- doc/configuration/instrumentation.md | 4 ++-- doc/migrations/6.2.1_x.x.x.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/configuration/instrumentation.md b/doc/configuration/instrumentation.md index 91709eee9c3..98e454bc149 100644 --- a/doc/configuration/instrumentation.md +++ b/doc/configuration/instrumentation.md @@ -92,7 +92,7 @@ In case both `prefix` and `env_prefix` are defined, it will be placed before the ## Log handler options ### `instrumentation.log.level` -* **Syntax:** string, one of `"none"`, `"emergency"`, `"alert"`, `"critical"`, `"error"`, `"warning"`, `"notice"`, `"info"`, `"debug"`, `"all"`. +* **Syntax:** string, one of `"emergency"`, `"alert"`, `"critical"`, `"error"`, `"warning"`, `"notice"`, `"info"`, `"debug"`, `"all"`. * **Default:** `"debug"` * **Example:** `loglevel = "error"` @@ -110,7 +110,7 @@ Note that for some events, the level may be different, and this option overridde This configuration enables `prometheus`, and `log` handlers: ```toml [instrumentation] - probe_interval = 10_000 + probe_interval = 60 [instrumentation.prometheus] diff --git a/doc/migrations/6.2.1_x.x.x.md b/doc/migrations/6.2.1_x.x.x.md index 0550ebb6e64..b595d3d332c 100644 --- a/doc/migrations/6.2.1_x.x.x.md +++ b/doc/migrations/6.2.1_x.x.x.md @@ -37,7 +37,7 @@ Exometer is no longer configured through [`app.config`](../configuration/configu Example configuration that is equivalent to the old example configuration provided in `app.config`: ```toml [instrumentation] - probe_interval = 60000 + probe_interval = 60 [[instrumentation.exometer.report.graphite]] host = "127.0.0.1" From f6e474e26a63ff46b38786d185fd16fb35218ff2 Mon Sep 17 00:00:00 2001 From: Janusz Jakubiec Date: Fri, 18 Oct 2024 14:54:30 +0200 Subject: [PATCH 2/2] Updating valid mongoose instrumentation log levels --- doc/configuration/instrumentation.md | 2 +- doc/migrations/6.2.1_x.x.x.md | 3 --- src/config/mongoose_config_validator.erl | 7 +++++++ src/instrument/mongoose_instrument_log.erl | 2 +- test/config_parser_SUITE.erl | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/configuration/instrumentation.md b/doc/configuration/instrumentation.md index 98e454bc149..9f34fa26664 100644 --- a/doc/configuration/instrumentation.md +++ b/doc/configuration/instrumentation.md @@ -107,7 +107,7 @@ Note that for some events, the level may be different, and this option overridde ## Example Prometheus configuration -This configuration enables `prometheus`, and `log` handlers: +This configuration enables `prometheus`, and `log` handlers, setting the periodic measurement (probe) interval to 60 seconds: ```toml [instrumentation] probe_interval = 60 diff --git a/doc/migrations/6.2.1_x.x.x.md b/doc/migrations/6.2.1_x.x.x.md index b595d3d332c..fe16e27a239 100644 --- a/doc/migrations/6.2.1_x.x.x.md +++ b/doc/migrations/6.2.1_x.x.x.md @@ -36,9 +36,6 @@ Exometer is no longer configured through [`app.config`](../configuration/configu Example configuration that is equivalent to the old example configuration provided in `app.config`: ```toml -[instrumentation] - probe_interval = 60 - [[instrumentation.exometer.report.graphite]] host = "127.0.0.1" port = 2003 diff --git a/src/config/mongoose_config_validator.erl b/src/config/mongoose_config_validator.erl index fd20ceb780a..2286348b5df 100644 --- a/src/config/mongoose_config_validator.erl +++ b/src/config/mongoose_config_validator.erl @@ -46,6 +46,7 @@ validate(V, atom, module) -> validate_module(V); validate(V, atom, {module, Prefix}) -> validate_module(list_to_atom(atom_to_list(Prefix) ++ "_" ++ atom_to_list(V))); validate(V, atom, loglevel) -> validate_loglevel(V); +validate(V, atom, instrumentation_loglevel) -> validate_instrumentation_loglevel(V); validate(V, atom, pool_name) -> validate_non_empty_atom(V); validate(V, atom, shaper) -> validate_non_empty_atom(V); validate(V, atom, access_rule) -> validate_non_empty_atom(V); @@ -64,6 +65,12 @@ validate_section([_|_], non_empty) -> ok; validate_section(L, any) when is_list(L) -> ok. %% validators +%% +validate_instrumentation_loglevel(none) -> + error(#{what => validate_instrumentation_loglevel_failed, + value => none}); +validate_instrumentation_loglevel(Level) -> + validate_loglevel(Level). validate_loglevel(Level) -> mongoose_logs:loglevel_keyword_to_number(Level). diff --git a/src/instrument/mongoose_instrument_log.erl b/src/instrument/mongoose_instrument_log.erl index 13ef08f5318..754f3f35b8b 100644 --- a/src/instrument/mongoose_instrument_log.erl +++ b/src/instrument/mongoose_instrument_log.erl @@ -9,7 +9,7 @@ -spec config_spec() -> mongoose_config_spec:config_section(). config_spec() -> - #section{items = #{<<"level">> => #option{type = atom, validate = loglevel}}, + #section{items = #{<<"level">> => #option{type = atom, validate = instrumentation_loglevel}}, defaults = #{<<"level">> => debug}}. -spec set_up(mongoose_instrument:event_name(), mongoose_instrument:labels(), diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index 8028c31a586..3922abc30de 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -2941,6 +2941,7 @@ instrumentation_log(_Config) -> T = fun(Opts) -> #{<<"instrumentation">> => #{<<"log">> => Opts}} end, ?cfg(P, default_config(P), T(#{})), ?cfg(P ++ [level], info, T(#{<<"level">> => <<"info">>})), + ?err(T(#{<<"level">> => <<"none">>})), ?err(T(#{<<"level">> => <<"insane">>})). instrumentation_exometer(_Config) ->