Merge pull request #7781 from HJianBo/rename-acl-metrics
feat(metrics): refactor authz metrics name
This commit is contained in:
commit
d36d27c533
|
@ -50,7 +50,7 @@ authorize(ClientInfo, PubSub, Topic) ->
|
||||||
true -> check_authorization_cache(ClientInfo, PubSub, Topic);
|
true -> check_authorization_cache(ClientInfo, PubSub, Topic);
|
||||||
false -> do_authorize(ClientInfo, PubSub, Topic)
|
false -> do_authorize(ClientInfo, PubSub, Topic)
|
||||||
end,
|
end,
|
||||||
inc_acl_metrics(Result),
|
inc_authz_metrics(Result),
|
||||||
Result.
|
Result.
|
||||||
|
|
||||||
check_authorization_cache(ClientInfo, PubSub, Topic) ->
|
check_authorization_cache(ClientInfo, PubSub, Topic) ->
|
||||||
|
@ -64,7 +64,7 @@ check_authorization_cache(ClientInfo, PubSub, Topic) ->
|
||||||
'client.check_authz_complete',
|
'client.check_authz_complete',
|
||||||
[ClientInfo, PubSub, Topic, AuthzResult, cache]
|
[ClientInfo, PubSub, Topic, AuthzResult, cache]
|
||||||
),
|
),
|
||||||
inc_acl_metrics(cache_hit),
|
inc_authz_metrics(cache_hit),
|
||||||
AuthzResult
|
AuthzResult
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ run_hooks(Name, Args, Acc) ->
|
||||||
ok = emqx_metrics:inc(Name),
|
ok = emqx_metrics:inc(Name),
|
||||||
emqx_hooks:run_fold(Name, Args, Acc).
|
emqx_hooks:run_fold(Name, Args, Acc).
|
||||||
|
|
||||||
-compile({inline, [inc_acl_metrics/1]}).
|
-compile({inline, [inc_authz_metrics/1]}).
|
||||||
inc_acl_metrics(allow) ->
|
inc_authz_metrics(allow) ->
|
||||||
emqx_metrics:inc('client.acl.allow');
|
emqx_metrics:inc('client.authorization.allow');
|
||||||
inc_acl_metrics(deny) ->
|
inc_authz_metrics(deny) ->
|
||||||
emqx_metrics:inc('client.acl.deny');
|
emqx_metrics:inc('client.authorization.deny');
|
||||||
inc_acl_metrics(cache_hit) ->
|
inc_authz_metrics(cache_hit) ->
|
||||||
emqx_metrics:inc('client.acl.cache_hit').
|
emqx_metrics:inc('client.authorization.cache_hit').
|
||||||
|
|
|
@ -255,9 +255,9 @@
|
||||||
|
|
||||||
%% Statistic metrics for ACL checking
|
%% Statistic metrics for ACL checking
|
||||||
-define(STASTS_ACL_METRICS, [
|
-define(STASTS_ACL_METRICS, [
|
||||||
{counter, 'client.acl.allow'},
|
{counter, 'client.authorization.allow'},
|
||||||
{counter, 'client.acl.deny'},
|
{counter, 'client.authorization.deny'},
|
||||||
{counter, 'client.acl.cache_hit'}
|
{counter, 'client.authorization.cache_hit'}
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% Overload protetion counters
|
%% Overload protetion counters
|
||||||
|
@ -677,9 +677,9 @@ reserved_idx('session.resumed') -> 221;
|
||||||
reserved_idx('session.takenover') -> 222;
|
reserved_idx('session.takenover') -> 222;
|
||||||
reserved_idx('session.discarded') -> 223;
|
reserved_idx('session.discarded') -> 223;
|
||||||
reserved_idx('session.terminated') -> 224;
|
reserved_idx('session.terminated') -> 224;
|
||||||
reserved_idx('client.acl.allow') -> 300;
|
reserved_idx('client.authorization.allow') -> 300;
|
||||||
reserved_idx('client.acl.deny') -> 301;
|
reserved_idx('client.authorization.deny') -> 301;
|
||||||
reserved_idx('client.acl.cache_hit') -> 302;
|
reserved_idx('client.authorization.cache_hit') -> 302;
|
||||||
reserved_idx('olp.delay.ok') -> 400;
|
reserved_idx('olp.delay.ok') -> 400;
|
||||||
reserved_idx('olp.delay.timeout') -> 401;
|
reserved_idx('olp.delay.timeout') -> 401;
|
||||||
reserved_idx('olp.hbn') -> 402;
|
reserved_idx('olp.hbn') -> 402;
|
||||||
|
|
|
@ -52,9 +52,9 @@
|
||||||
|
|
||||||
-type sources() :: [source()].
|
-type sources() :: [source()].
|
||||||
|
|
||||||
-define(METRIC_ALLOW, 'client.authorize.allow').
|
-define(METRIC_ALLOW, 'client.authorization.matched.allow').
|
||||||
-define(METRIC_DENY, 'client.authorize.deny').
|
-define(METRIC_DENY, 'client.authorization.matched.deny').
|
||||||
-define(METRIC_NOMATCH, 'client.authorize.nomatch').
|
-define(METRIC_NOMATCH, 'client.authorization.nomatch').
|
||||||
|
|
||||||
-define(METRICS, [?METRIC_ALLOW, ?METRIC_DENY, ?METRIC_NOMATCH]).
|
-define(METRICS, [?METRIC_ALLOW, ?METRIC_DENY, ?METRIC_NOMATCH]).
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ t_check_expire(_Config) ->
|
||||||
Payload = #{
|
Payload = #{
|
||||||
<<"username">> => <<"username">>,
|
<<"username">> => <<"username">>,
|
||||||
<<"acl">> => #{<<"sub">> => [<<"a/b">>]},
|
<<"acl">> => #{<<"sub">> => [<<"a/b">>]},
|
||||||
<<"exp">> => erlang:system_time(second) + 1
|
<<"exp">> => erlang:system_time(second) + 5
|
||||||
},
|
},
|
||||||
|
|
||||||
JWT = generate_jws(Payload),
|
JWT = generate_jws(Payload),
|
||||||
|
@ -270,7 +270,7 @@ t_check_expire(_Config) ->
|
||||||
emqtt:unsubscribe(C, <<"a/b">>)
|
emqtt:unsubscribe(C, <<"a/b">>)
|
||||||
),
|
),
|
||||||
|
|
||||||
timer:sleep(2000),
|
timer:sleep(6000),
|
||||||
|
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
{ok, #{}, [?RC_NOT_AUTHORIZED]},
|
{ok, #{}, [?RC_NOT_AUTHORIZED]},
|
||||||
|
|
Loading…
Reference in New Issue