Skip to content

Commit

Permalink
Type more strictly between global and host_types
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed May 20, 2022
1 parent 79742d3 commit d9c72a3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/metrics/mongoose_metrics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ensure_db_pool_metric({rdbms, Host, Tag} = Name) ->
{function, mongoose_metrics, get_rdbms_data_stats, [[Name]], proplist,
[workers | ?INET_STATS]}).

-spec update(HostType :: mongooseim:host_type() | global, Name :: term() | list(),
-spec update(HostType :: mongooseim:host_type_or_global(), Name :: term() | list(),
Change :: term()) -> any().
update(HostType, Name, Change) when is_list(Name) ->
exometer:update(name_by_all_metrics_are_global(HostType, Name), Change);
Expand Down Expand Up @@ -208,16 +208,16 @@ prepare_prefixes() ->
all_metrics_are_global() ->
mongoose_config:get_opt(all_metrics_are_global).

get_host_type_prefix(HostType) when is_atom(HostType) ->
HostType;
get_host_type_prefix(global) ->
global;
get_host_type_prefix(HostType) when is_binary(HostType) ->
case persistent_term:get(?PREFIXES, #{}) of
#{HostType := HostTypePrefix} -> HostTypePrefix;
#{} -> make_host_type_prefix(HostType)
end.

make_host_type_prefix(HT) when is_atom(HT) ->
HT;
make_host_type_prefix(global) ->
global;
make_host_type_prefix(HT) when is_binary(HT) ->
binary:replace(HT, <<" ">>, <<"_">>, [global]).

Expand Down

0 comments on commit d9c72a3

Please sign in to comment.