Skip to content

Commit

Permalink
Merge pull request #4382 from esl/instrumentation-docs-update
Browse files Browse the repository at this point in the history
Updating documentation
  • Loading branch information
chrzaszcz authored Oct 18, 2024
2 parents 1e890ff + f6e474e commit 2d0db0e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions doc/configuration/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand All @@ -107,10 +107,10 @@ 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 = 10_000
probe_interval = 60

[instrumentation.prometheus]

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 = 60000

[[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);
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,
value => none});
validate_instrumentation_loglevel(Level) ->
validate_loglevel(Level).

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 @@ -2961,6 +2961,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 2d0db0e

Please sign in to comment.