Skip to content

Commit

Permalink
Merge fdf98fd into 8f2bf66
Browse files Browse the repository at this point in the history
  • Loading branch information
kzemek authored Aug 8, 2018
2 parents 8f2bf66 + fdf98fd commit da2b9dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/mongoose_metrics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ pick_by_all_metrics_are_global(WhenGlobal, WhenNot) ->

-spec name_by_all_metrics_are_global(Host :: jid:lserver() | global,
Name :: list()) -> FinalName :: list().
name_by_all_metrics_are_global(Host, Name) ->
name_by_all_metrics_are_global(global, Name) -> [global | Name];
name_by_all_metrics_are_global(Host0, Name) ->
Host = binary:replace(Host0, <<$.>>, <<$_>>, [global]),
pick_by_all_metrics_are_global([global | Name], [Host | Name]).

get_report_interval() ->
Expand Down
9 changes: 8 additions & 1 deletion test/mongooseim_metrics_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ all() ->

groups() ->
[
{ordinary_mode, [], ?ALL_CASES},
{ordinary_mode, [], [dots_in_host_are_turned_to_underscore | ?ALL_CASES]},
{all_metrics_are_global, [], ?ALL_CASES}
].

Expand Down Expand Up @@ -83,6 +83,13 @@ subscriptions_initialised(_C) ->
mongoose_metrics:init(),
true = wait_for_update(exometer:get_value([carbon, packets], count), 60).

dots_in_host_are_turned_to_underscore(_C) ->
mongoose_metrics:init(),
mongoose_metrics:ensure_metric(<<"host.with.dots">>, [a, metric, value], histogram),
mongoose_metrics:update(<<"host.with.dots">>, [a, metric, value], 10),
{ok, _} = exometer:get_value([<<"host_with_dots">>, a, metric, value]).


wait_for_update({ok, [{count,X}]}, 0) ->
X > 0;
wait_for_update({ok, [{count,X}]}, _N) when X > 0 ->
Expand Down

0 comments on commit da2b9dd

Please sign in to comment.