Skip to content

Commit

Permalink
Updating valid mongoose instrumentation log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
JanuszJakubiec committed Oct 18, 2024
1 parent 24f397f commit f6e474e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/configuration/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions doc/migrations/6.2.1_x.x.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/config/mongoose_config_validator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 49 in src/config/mongoose_config_validator.erl

View check run for this annotation

Codecov / codecov/patch

src/config/mongoose_config_validator.erl#L49

Added line #L49 was not covered by tests
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);
Expand All @@ -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,

Check warning on line 70 in src/config/mongoose_config_validator.erl

View check run for this annotation

Codecov / codecov/patch

src/config/mongoose_config_validator.erl#L70

Added line #L70 was not covered by tests
value => none});
validate_instrumentation_loglevel(Level) ->
validate_loglevel(Level).

Check warning on line 73 in src/config/mongoose_config_validator.erl

View check run for this annotation

Codecov / codecov/patch

src/config/mongoose_config_validator.erl#L73

Added line #L73 was not covered by tests

validate_loglevel(Level) ->
mongoose_logs:loglevel_keyword_to_number(Level).
Expand Down
2 changes: 1 addition & 1 deletion src/instrument/mongoose_instrument_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down

0 comments on commit f6e474e

Please sign in to comment.