From 4a6dabbe57ad9edb7dfa33ee19baf8b9b2a1372c Mon Sep 17 00:00:00 2001 From: EMQ-YangM Date: Fri, 29 Apr 2022 11:44:15 +0800 Subject: [PATCH] fix: rename to emqx_metrics_worker --- apps/emqx_authz/src/emqx_authz.erl | 14 +++++++------- apps/emqx_authz/src/emqx_authz_api_sources.erl | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/emqx_authz/src/emqx_authz.erl b/apps/emqx_authz/src/emqx_authz.erl index a493e339d..4e498c237 100644 --- a/apps/emqx_authz/src/emqx_authz.erl +++ b/apps/emqx_authz/src/emqx_authz.erl @@ -173,7 +173,7 @@ do_post_config_update({?CMD_PREPEND, RawNewSource}, Sources) -> InitedNewSource = init_source(get_source_by_type(type(RawNewSource), Sources)), %% create metrics TypeName = type(RawNewSource), - ok = emqx_plugin_libs_metrics:create_metrics( + ok = emqx_metrics_worker:create_metrics( authz_metrics, TypeName, [matched, allow, deny, ignore], @@ -194,7 +194,7 @@ do_post_config_update({{?CMD_DELETE, Type}, _RawNewSource}, _Sources) -> OldInitedSources = lookup(), {OldSource, Front, Rear} = take(Type, OldInitedSources), %% delete metrics - ok = emqx_plugin_libs_metrics:clear_metrics(authz_metrics, Type), + ok = emqx_metrics_worker:clear_metrics(authz_metrics, Type), ok = ensure_resource_deleted(OldSource), clear_certs(OldSource), Front ++ Rear; @@ -268,7 +268,7 @@ init_source(#{type := Type} = Source) -> init_metrics(Source) -> TypeName = type(Source), - emqx_plugin_libs_metrics:create_metrics( + emqx_metrics_worker:create_metrics( authz_metrics, TypeName, [matched, allow, deny, ignore], @@ -310,7 +310,7 @@ authorize( ipaddr => IpAddress, topic => Topic }), - emqx_plugin_libs_metrics:inc(authz_metrics, AuthzSource, allow), + emqx_metrics_worker:inc(authz_metrics, AuthzSource, allow), emqx_metrics:inc(?METRIC_ALLOW), {stop, allow}; {{matched, deny}, AuthzSource} -> @@ -324,7 +324,7 @@ authorize( ipaddr => IpAddress, topic => Topic }), - emqx_plugin_libs_metrics:inc(authz_metrics, AuthzSource, deny), + emqx_metrics_worker:inc(authz_metrics, AuthzSource, deny), emqx_metrics:inc(?METRIC_DENY), {stop, deny}; nomatch -> @@ -354,10 +354,10 @@ do_authorize( [Connector = #{type := Type} | Tail] ) -> Module = authz_module(Type), - emqx_plugin_libs_metrics:inc(authz_metrics, Type, matched), + emqx_metrics_worker:inc(authz_metrics, Type, matched), case Module:authorize(Client, PubSub, Topic, Connector) of nomatch -> - emqx_plugin_libs_metrics:inc(authz_metrics, Type, ignore), + emqx_metrics_worker:inc(authz_metrics, Type, ignore), do_authorize(Client, PubSub, Topic, Tail); Matched -> {Matched, Type} diff --git a/apps/emqx_authz/src/emqx_authz_api_sources.erl b/apps/emqx_authz/src/emqx_authz_api_sources.erl index c5920dd14..72fa10c98 100644 --- a/apps/emqx_authz/src/emqx_authz_api_sources.erl +++ b/apps/emqx_authz/src/emqx_authz_api_sources.erl @@ -308,7 +308,7 @@ lookup_from_local_node(Type) -> NodeId = node(self()), try emqx_authz:lookup(Type) of #{annotations := #{id := ResourceId}} -> - Metrics = emqx_plugin_libs_metrics:get_metrics(authz_metrics, Type), + Metrics = emqx_metrics_worker:get_metrics(authz_metrics, Type), case emqx_resource:get_instance(ResourceId) of {error, not_found} -> {error, {NodeId, not_found_resource}}; @@ -316,7 +316,7 @@ lookup_from_local_node(Type) -> {ok, {NodeId, Status, Metrics, ResourceMetrics}} end; _ -> - Metrics = emqx_plugin_libs_metrics:get_metrics(authz_metrics, Type), + Metrics = emqx_metrics_worker:get_metrics(authz_metrics, Type), {ok, {NodeId, connected, Metrics, #{}}} catch _:Reason -> {error, {NodeId, list_to_binary(io_lib:format("~p", [Reason]))}}