diff --git a/src/mongoose_metrics.erl b/src/mongoose_metrics.erl index 70cdb95058c..1cd3c02b1ca 100644 --- a/src/mongoose_metrics.erl +++ b/src/mongoose_metrics.erl @@ -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() -> diff --git a/test/mongooseim_metrics_SUITE.erl b/test/mongooseim_metrics_SUITE.erl index 0e88859b453..77d04e95624 100644 --- a/test/mongooseim_metrics_SUITE.erl +++ b/test/mongooseim_metrics_SUITE.erl @@ -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} ]. @@ -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 ->