From 020617db86bd18a60becf703d8174984f6f614fa Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Wed, 27 Mar 2024 11:31:40 +0530 Subject: [PATCH 01/11] feat: add new plugin for metrics --- .../src/vmq_enhanced_auth.erl | 44 +++--- apps/vmq_metrics_plus/rebar.config | 5 + .../src/vmq_metrics_plus.app.src | 24 +++ .../vmq_metrics_plus/src/vmq_metrics_plus.erl | 139 ++++++++++++++++++ .../src/vmq_metrics_plus_app.erl | 18 +++ .../src/vmq_metrics_plus_plugin.erl | 107 ++++++++++++++ .../src/vmq_metrics_plus_sup.erl | 32 ++++ apps/vmq_server/priv/vmq_server.schema | 5 + apps/vmq_server/src/vmq_metrics.erl | 77 +--------- apps/vmq_server/src/vmq_mqtt_fsm.erl | 4 - apps/vmq_server/src/vmq_queue.erl | 2 - rebar.config | 1 + 12 files changed, 356 insertions(+), 102 deletions(-) create mode 100644 apps/vmq_metrics_plus/rebar.config create mode 100644 apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src create mode 100644 apps/vmq_metrics_plus/src/vmq_metrics_plus.erl create mode 100644 apps/vmq_metrics_plus/src/vmq_metrics_plus_app.erl create mode 100644 apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl create mode 100644 apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl diff --git a/apps/vmq_enhanced_auth/src/vmq_enhanced_auth.erl b/apps/vmq_enhanced_auth/src/vmq_enhanced_auth.erl index 9a583d861..4106c2ba4 100644 --- a/apps/vmq_enhanced_auth/src/vmq_enhanced_auth.erl +++ b/apps/vmq_enhanced_auth/src/vmq_enhanced_auth.erl @@ -26,7 +26,7 @@ init/0, load_from_file/1, load_from_list/1, - check/5, + check/4, set_acl_version_metrics/1 ]). @@ -110,12 +110,7 @@ auth_on_subscribe(RegView, User, SubscriberId, [{Topic, Qos} | Rest], Modifiers) D -> next; true -> - QosValue = - case Qos of - N when is_integer(N) -> N; - {N, _} when is_integer(N) -> N - end, - case check(read, Topic, User, SubscriberId, QosValue) of + case check(read, Topic, User, SubscriberId) of {true, MatchedAcl} -> auth_on_subscribe( User, @@ -134,13 +129,13 @@ auth_on_subscribe(RegView, User, SubscriberId, [{Topic, Qos} | Rest], Modifiers) end end. -auth_on_publish(User, SubscriberId, Qos, Topic, _, _) -> +auth_on_publish(User, SubscriberId, _Qos, Topic, _, _) -> D = is_acl_auth_disabled(), if D -> next; true -> - case check(write, Topic, User, SubscriberId, Qos) of + case check(write, Topic, User, SubscriberId) of {true, MatchedAcl} -> {ok, [{matched_acl, MatchedAcl}]}; false -> @@ -151,7 +146,7 @@ auth_on_publish(User, SubscriberId, Qos, Topic, _, _) -> auth_on_subscribe_m5(_, _, []) -> ok; auth_on_subscribe_m5(User, SubscriberId, [{Topic, _Qos} | Rest]) -> - case check(read, Topic, User, SubscriberId, _Qos) of + case check(read, Topic, User, SubscriberId) of {true, _} -> auth_on_subscribe(User, SubscriberId, Rest); false -> @@ -321,56 +316,56 @@ parse_acl_line({F, eof}, _User) -> F(F, close), ok. -check(Type, [Word | _] = Topic, User, SubscriberId, Qos) when is_binary(Word) -> - case check_all_acl(Type, Topic, Qos) of +check(Type, [Word | _] = Topic, User, SubscriberId) when is_binary(Word) -> + case check_all_acl(Type, Topic) of {true, MatchedAcl} -> {true, MatchedAcl}; false when User == all -> false; false -> - case check_user_acl(Type, User, Topic, Qos) of + case check_user_acl(Type, User, Topic) of {true, MatchedAcl} -> {true, MatchedAcl}; false -> - case check_pattern_acl(Type, Topic, User, SubscriberId, Qos) of + case check_pattern_acl(Type, Topic, User, SubscriberId) of {true, MatchedAcl} -> {true, MatchedAcl}; false -> - check_token_acl(Type, Topic, User, SubscriberId, Qos) + check_token_acl(Type, Topic, User, SubscriberId) end end end. -check_all_acl(Type, TIn, Qos) -> +check_all_acl(Type, TIn) -> Tbl = t(Type, all), iterate_until_true(Tbl, fun(T) -> - match(TIn, T, Tbl, Type, T, Qos) + match(TIn, T, Tbl, T) end). -check_user_acl(Type, User, TIn, Qos) -> +check_user_acl(Type, User, TIn) -> Tbl = t(Type, User), iterate_until_true( ets:match(Tbl, {{User, '$1'}, '_', '_'}), fun([T]) -> Key = {User, T}, - match(TIn, T, Tbl, Type, Key, Qos) + match(TIn, T, Tbl, Key) end ). -check_pattern_acl(Type, TIn, User, SubscriberId, Qos) -> +check_pattern_acl(Type, TIn, User, SubscriberId) -> Tbl = t(Type, pattern), iterate_until_true(Tbl, fun(P) -> T = topic(User, SubscriberId, P), - match(TIn, T, Tbl, Type, P, Qos) + match(TIn, T, Tbl, P) end). -check_token_acl(Type, TIn, User, SubscriberId, Qos) -> +check_token_acl(Type, TIn, User, SubscriberId) -> Tbl = t(Type, token), iterate_until_true(Tbl, fun(P) -> T = topic(User, SubscriberId, P), - match(TIn, T, Tbl, Type, P, Qos) + match(TIn, T, Tbl, P) end). -match(TIn, T, Tbl, Type, Key, Qos) -> +match(TIn, T, Tbl, Key) -> case match(TIn, T) of true -> case ets:lookup(Tbl, Key) of @@ -380,7 +375,6 @@ match(TIn, T, Tbl, Type, Key, Qos) -> }, {true, MatchedAcl}; [{_, _, Label}] -> - vmq_metrics:incr_matched_topic(Label, Type, Qos), MatchedAcl = #matched_acl{ name = Label, pattern = iolist_to_binary(vmq_topic:unword(T)) }, diff --git a/apps/vmq_metrics_plus/rebar.config b/apps/vmq_metrics_plus/rebar.config new file mode 100644 index 000000000..60caa23d6 --- /dev/null +++ b/apps/vmq_metrics_plus/rebar.config @@ -0,0 +1,5 @@ +{erl_opts, [ + {parse_transform, lager_transform}, + warnings_as_errors, + debug_info +]}. diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src b/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src new file mode 100644 index 000000000..02ac085d3 --- /dev/null +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src @@ -0,0 +1,24 @@ +{application, vmq_metrics_plus, [ + {description, "VerneMQ metrics plugin"}, + {vsn, git}, + {registered, []}, + {mod, {vmq_metrics_plus_app, []}}, + {applications, [ + kernel, + stdlib, + lager + ]}, + {env, [ + {vmq_plugin_hooks, [ + {vmq_metrics_plus_plugin, on_subscribe, 3, []}, + {vmq_metrics_plus_plugin, on_publish, 7, []}, + {vmq_metrics_plus_plugin, on_deliver, 8, []}, + {vmq_metrics_plus_plugin, on_delivery_complete, 8, []}, + {vmq_metrics_plus_plugin, on_message_drop, 3, []} + ]} + ]}, + {modules, []}, + + {licenses, ["Apache 2.0"]}, + {links, []} +]}. diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl new file mode 100644 index 000000000..30c442bf5 --- /dev/null +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl @@ -0,0 +1,139 @@ +%% Copyright 2018 Octavo Labs AG Zurich Switzerland (https://octavolabs.com) +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. + +-module(vmq_metrics_plus). +-include_lib("apps/vmq_server/src/vmq_metrics.hrl"). + +-behaviour(gen_server). + +%% API +-export([ + start_link/0 +]). + +%% gen_server callbacks +-export([ + init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + terminate/2, + code_change/3 +]). + +-export([ + metrics/0, + incr_matched_topic/3 +]). + +-define(SERVER, ?MODULE). +-define(TOPIC_LABEL_TABLE, topic_labels). + +-record(state, {}). + +%%%=================================================================== +%%% API +%%%=================================================================== + +start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + +metrics() -> + {TopicMetricsDefs, TopicMetricsValues} = topic_metrics(), + MetricDefs = TopicMetricsDefs, + MetricValues = TopicMetricsValues, + {MetricDefs, MetricValues}. + +topic_metrics() -> + ets:foldl( + fun({Metric, TotalCount}, {DefsAcc, ValsAcc}) -> + {UniqueId, MetricName, Description, Labels} = topic_metric_name(Metric), + {[m(counter, Labels, UniqueId, MetricName, Description) | DefsAcc], [ + {UniqueId, TotalCount} | ValsAcc + ]} + end, + {[], []}, + ?TOPIC_LABEL_TABLE + ). + +-type metric_type() :: subscribe | publish | deliver | delivery_complete | message_drop. + +-spec incr_topic_counter( + Metric :: {topic_matches, metric_type(), Labels :: [{atom(), atom() | list() | binary()}]} +) -> ok. +incr_topic_counter(Metric) -> + try + ets:update_counter(?TOPIC_LABEL_TABLE, Metric, 1) + catch + _:_ -> + try + ets:insert_new(?TOPIC_LABEL_TABLE, {Metric, 0}), + incr_topic_counter(Metric) + catch + _:_ -> + lager:warning("couldn't initialize tables", []) + end + end. + +-spec incr_matched_topic(binary() | undefined, metric_type(), integer()) -> ok. +incr_matched_topic(<<>>, _Type, _Qos) -> + ok; +incr_matched_topic(undefined, _Type, _Qos) -> + ok; +incr_matched_topic(Name, Type, Qos) -> + incr_topic_counter({topic_matches, Type, [{acl_matched, Name}, {qos, integer_to_list(Qos)}]}). + +%%%=================================================================== +%%% gen_server callbacks +%%%=================================================================== + +init([]) -> + ets:new(?TOPIC_LABEL_TABLE, [named_table, public, {write_concurrency, true}]), + {ok, #state{}}. + +handle_call(_Request, _From, State) -> + Reply = ok, + {reply, Reply, State}. + +handle_cast(_Msg, State) -> + {noreply, State}. + +handle_info(_Info, State) -> + {noreply, State}. + +terminate(_Reason, _State) -> + ok. + +code_change(_OldVsn, State, _Extra) -> + {ok, State}. + +%%%=================================================================== + +m(Type, Labels, UniqueId, Name, Description) -> + #metric_def{ + type = Type, + labels = Labels, + id = UniqueId, + name = Name, + description = Description + }. + +topic_metric_name({Metric, SubMetric, Labels}) -> + LMetric = atom_to_list(Metric), + LSubMetric = atom_to_list(SubMetric), + MetricName = list_to_atom(LSubMetric ++ "_" ++ LMetric), + Description = list_to_binary( + "The number of " ++ LSubMetric ++ " packets on ACL matched topics." + ), + {[MetricName | Labels], MetricName, Description, Labels}. diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_app.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_app.erl new file mode 100644 index 000000000..e43f99065 --- /dev/null +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_app.erl @@ -0,0 +1,18 @@ +%%%------------------------------------------------------------------- +%% @doc vmq_metric_plus public API +%% @end +%%%------------------------------------------------------------------- + +-module(vmq_metrics_plus_app). + +-behaviour(application). + +-export([start/2, stop/1]). + +start(_StartType, _StartArgs) -> + vmq_metrics_plus_sup:start_link(). + +stop(_State) -> + ok. + +%% internal functions diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl new file mode 100644 index 000000000..d86a6c516 --- /dev/null +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl @@ -0,0 +1,107 @@ +%% Copyright Gojek + +-module(vmq_metrics_plus_plugin). + +-include_lib("vernemq_dev/include/vernemq_dev.hrl"). +-include_lib("vmq_commons/src/vmq_types_common.hrl"). + +-behaviour(on_publish_hook). +-behaviour(on_subscribe_hook). +-behaviour(on_deliver_hook). +-behaviour(on_delivery_complete_hook). +-behaviour(on_message_drop_hook). + +-export([ + on_subscribe/3, + on_publish/7, + on_deliver/8, + on_delivery_complete/8, + on_message_drop/3 +]). + +-export([ + start/0, + stop/0 +]). + +-type reason() :: atom(). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Plugin Callbacks +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +start() -> + {ok, _} = application:ensure_all_started(vmq_metrics_plus_plugin), + ok. + +stop() -> + application:stop(vmq_metrics_plus_plugin). + +%%-------------------------------------------------------------------- +%%%=================================================================== +%%% Hook functions +%%%=================================================================== +%% called as an all_till_ok hook +%% +-spec on_subscribe(username(), subscriber_id(), [{topic(), qos(), matched_acl()}]) -> 'next'. +on_subscribe(_UserName, _SubscriberId, Topics) -> + lists:foreach( + fun(T) -> + {_Topic, QoS, #matched_acl{name = Name}} = T, + vmq_metrics_plus:incr_matched_topic(Name, subscribe, QoS) + end, + Topics + ), + next. + +-spec on_publish(username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl()) -> + 'next'. +on_publish(_UserName, _SubscriberId, QoS, _Topic, _Payload, _IsRetain, #matched_acl{name = Name}) -> + vmq_metrics_plus:incr_matched_topic(Name, publish, QoS), + next. + +-spec on_deliver( + username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() +) -> + 'next' | 'ok' | {'ok', payload() | [on_deliver_hook:msg_modifier()]}. +on_deliver( + _UserName, + _SubscriberId, + QoS, + _Topic, + _Payload, + _IsRetain, + #matched_acl{name = Name}, + _Persisted +) -> + vmq_metrics_plus:incr_matched_topic(Name, deliver, QoS), + next. + +-spec on_delivery_complete( + username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() +) -> + 'next'. +on_delivery_complete( + _UserName, + _SubscriberId, + QoS, + _Topic, + _Payload, + _IsRetain, + #matched_acl{name = Name}, + _Persisted +) -> + vmq_metrics_plus:incr_matched_topic(Name, delivery_complete, QoS), + next. + +-spec on_message_drop(subscriber_id(), fun(), reason()) -> 'next'. +on_message_drop(SubscriberId, Fun, Reason) -> + case Fun() of + {_Topic, QoS, _Payload, _Props, #matched_acl{name = Name}} -> + vmq_metrics_plus:incr_matched_topic(Name, message_drop, QoS), + next; + _ -> + lager:error("unexpected pattern in on_message_drop hook for ~p due to reason ~p", [ + SubscriberId, Reason + ]), + next + end. diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl new file mode 100644 index 000000000..3d170f3cd --- /dev/null +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl @@ -0,0 +1,32 @@ +%%%------------------------------------------------------------------- +%% @doc vmq_metric_plus top level supervisor. +%% @end +%%%------------------------------------------------------------------- + +-module(vmq_metrics_plus_sup). + +-behaviour(supervisor). + +-export([start_link/0]). + +-export([init/1]). + +-define(SERVER, ?MODULE). + +%% Helper macro for declaring children of supervisor +-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). + +start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + +%% sup_flags() = #{strategy => strategy(), % optional +%% intensity => non_neg_integer(), % optional +%% period => pos_integer()} % optional +%% child_spec() = #{id => child_id(), % mandatory +%% start => mfargs(), % mandatory +%% restart => restart(), % optional +%% shutdown => shutdown(), % optional +%% type => worker(), % optional +%% modules => modules()} % optional +init([]) -> + {ok, {{one_for_one, 5, 10}, [?CHILD(vmq_metrics_plus, worker)]}}. diff --git a/apps/vmq_server/priv/vmq_server.schema b/apps/vmq_server/priv/vmq_server.schema index c493d5aba..a6d73a19e 100644 --- a/apps/vmq_server/priv/vmq_server.schema +++ b/apps/vmq_server/priv/vmq_server.schema @@ -1679,6 +1679,11 @@ {default, off} ]}. +%% @doc File based metrics plugin. +{mapping, "plugins.vmq_metrics_plus", "vmq_server.user_plugins", [ + {datatype, flag}, + {default, on} + ]}. {translation, "vmq_server.user_plugins", fun(Conf) -> diff --git a/apps/vmq_server/src/vmq_metrics.erl b/apps/vmq_server/src/vmq_metrics.erl index aaa2cab4e..533bfb365 100644 --- a/apps/vmq_server/src/vmq_metrics.erl +++ b/apps/vmq_server/src/vmq_metrics.erl @@ -99,8 +99,6 @@ incr_cache_miss/1, incr_msg_enqueue_subscriber_not_found/0, - incr_topic_counter/1, - incr_matched_topic/3, incr_shared_subscription_group_publish_attempt_failed/0, incr_events_sampled/2, @@ -134,7 +132,6 @@ ]). -define(TIMER_TABLE, vmq_metrics_timers). --define(TOPIC_LABEL_TABLE, topic_labels). -define(EVENTS_SAMPLING_TABLE, vmq_metrics_events_sampling). -define(CONFIG_VERION_TABLE, config_version_table). @@ -442,16 +439,16 @@ metrics(Opts) -> {PluggableMetricDefs, PluggableMetricValues} = pluggable_metrics(), {HistogramMetricDefs, HistogramMetricValues} = histogram_metrics(), - {TopicMetricsDefs, TopicMetricsValues} = topic_metrics(), {EventsSamplingMetricsDefs, EventsSamplingMetricsValues} = events_sampling_metrics(), {ConfigVersionMetricsDefs, ConfigVersionMetricsValues} = config_version_metrics(), + {PluginMetricDef, PluginMetricValues} = vmq_metrics_plus:metrics(), MetricDefs = - metric_defs() ++ PluggableMetricDefs ++ HistogramMetricDefs ++ TopicMetricsDefs ++ - EventsSamplingMetricsDefs ++ ConfigVersionMetricsDefs, + metric_defs() ++ PluggableMetricDefs ++ HistogramMetricDefs ++ + EventsSamplingMetricsDefs ++ ConfigVersionMetricsDefs ++ PluginMetricDef, MetricValues = - metric_values() ++ PluggableMetricValues ++ HistogramMetricValues ++ TopicMetricsValues ++ - EventsSamplingMetricsValues ++ ConfigVersionMetricsValues, + metric_values() ++ PluggableMetricValues ++ HistogramMetricValues ++ + EventsSamplingMetricsValues ++ ConfigVersionMetricsValues ++ PluginMetricValues, %% Create id->metric def map IdDef = lists:foldl( @@ -569,22 +566,6 @@ histogram_metrics() -> Histogram ). -topic_metric_defs() -> - {Defs, _} = topic_metrics(), - Defs. - -topic_metrics() -> - ets:foldl( - fun({Metric, TotalCount}, {DefsAcc, ValsAcc}) -> - {UniqueId, MetricName, Description, Labels} = topic_metric_name(Metric), - {[m(counter, Labels, UniqueId, MetricName, Description) | DefsAcc], [ - {UniqueId, TotalCount} | ValsAcc - ]} - end, - {[], []}, - ?TOPIC_LABEL_TABLE - ). - events_sampling_metric_defs() -> {Defs, _} = events_sampling_metrics(), Defs. @@ -640,42 +621,6 @@ incr_histogram_buckets(Metric, BucketOps) -> end end. --type metric_type() :: subscribe | publish | deliver | delivery_complete | message_drop. --spec incr_topic_counter( - Metric :: {topic_matches, metric_type(), Labels :: [{atom(), atom() | list() | binary()}]} -) -> ok. -incr_topic_counter(Metric) -> - try - ets:update_counter(?TOPIC_LABEL_TABLE, Metric, 1) - catch - _:_ -> - try - ets:insert_new(?TOPIC_LABEL_TABLE, {Metric, 0}), - incr_topic_counter(Metric) - catch - _:_ -> - lager:warning("couldn't initialize tables", []) - end - end. - --spec incr_matched_topic(binary() | undefined, atom(), integer()) -> ok. -incr_matched_topic(<<>>, _Type, _Qos) -> - ok; -incr_matched_topic(undefined, _Type, _Qos) -> - ok; -incr_matched_topic(Name, Type, Qos) -> - OperationName = - case Type of - read -> subscribe; - write -> publish; - _ -> Type - end, - incr_topic_counter( - {topic_matches, OperationName, [ - {acl_matched, Name}, {qos, integer_to_list(Qos)} - ]} - ). - config_version_metric_defs() -> {Defs, _} = config_version_metrics(), Defs. @@ -748,7 +693,7 @@ get_label_info() -> end, #{}, metric_defs() ++ pluggable_metric_defs() ++ histogram_metric_defs() ++ - topic_metric_defs() ++ events_sampling_metric_defs() ++ config_version_metric_defs() + events_sampling_metric_defs() ++ config_version_metric_defs() ), maps:to_list(LabelInfo). @@ -786,7 +731,6 @@ init([]) -> NumEntries = length(lists:usort(Idxs)), ets:new(?TIMER_TABLE, [named_table, public, {write_concurrency, true}]), - ets:new(?TOPIC_LABEL_TABLE, [named_table, public, {write_concurrency, true}]), ets:new(?EVENTS_SAMPLING_TABLE, [named_table, public, {write_concurrency, true}]), ets:new(?CONFIG_VERION_TABLE, [named_table, public, {write_concurrency, true}]), @@ -2985,15 +2929,6 @@ metric_name({Metric, SubMetric}) -> ), {Name, Name, Description, []}. -topic_metric_name({Metric, SubMetric, Labels}) -> - LMetric = atom_to_list(Metric), - LSubMetric = atom_to_list(SubMetric), - MetricName = list_to_atom(LSubMetric ++ "_" ++ LMetric), - Description = list_to_binary( - "The number of " ++ LSubMetric ++ " packets on ACL matched topics." - ), - {[MetricName | Labels], MetricName, Description, Labels}. - events_sampled_metric_name(H, C, SDType) -> Name = list_to_atom("vmq_events_" ++ SDType), Labels = [{hook, atom_to_list(H)}, {acl_name, C}], diff --git a/apps/vmq_server/src/vmq_mqtt_fsm.erl b/apps/vmq_server/src/vmq_mqtt_fsm.erl index 92b4c9410..7fb49bdcb 100644 --- a/apps/vmq_server/src/vmq_mqtt_fsm.erl +++ b/apps/vmq_server/src/vmq_mqtt_fsm.erl @@ -340,7 +340,6 @@ connected( acl_name = Name, persisted = Persisted } -> - vmq_metrics:incr_matched_topic(Name, delivery_complete, QoS), _ = vmq_plugin:all(on_delivery_complete, [ Username, SubscriberId, @@ -375,7 +374,6 @@ connected(#mqtt_pubrec{message_id = MessageId}, State) -> acl_name = Name, persisted = Persisted } -> - vmq_metrics:incr_matched_topic(Name, delivery_complete, QoS), _ = vmq_plugin:all(on_delivery_complete, [ Username, SubscriberId, @@ -1318,8 +1316,6 @@ on_deliver_hook(User, SubscriberId, QoS, Topic, Payload, IsRetain, MatchedAcl, P HookArgs0 = [User, SubscriberId, Topic, Payload], case vmq_plugin:all_till_ok(on_deliver, HookArgs0) of {error, _} -> - #matched_acl{name = Name} = MatchedAcl, - vmq_metrics:incr_matched_topic(Name, deliver, QoS), HookArgs1 = [User, SubscriberId, QoS, Topic, Payload, IsRetain, MatchedAcl, Persisted], vmq_plugin:all_till_ok(on_deliver, HookArgs1); Other -> diff --git a/apps/vmq_server/src/vmq_queue.erl b/apps/vmq_server/src/vmq_queue.erl index 4537a0b28..b30f42ca5 100644 --- a/apps/vmq_server/src/vmq_queue.erl +++ b/apps/vmq_server/src/vmq_queue.erl @@ -1423,7 +1423,6 @@ on_message_drop_hook( }, Reason ) -> - vmq_metrics:incr_matched_topic(Name, message_drop, QoS), vmq_plugin:all(on_message_drop, [ SubscriberId, fun() -> {RoutingKey, QoS, Payload, Props, #matched_acl{name = Name}} end, @@ -1439,7 +1438,6 @@ on_message_drop_hook(SubscriberId, MsgRef, Reason) when is_binary(MsgRef) -> properties = Props, acl_name = Name }} -> - vmq_metrics:incr_matched_topic(Name, message_drop, QoS), {RoutingKey, QoS, Payload, Props, #matched_acl{name = Name}}; _ -> error diff --git a/rebar.config b/rebar.config index a7b89109b..9bf9e0136 100644 --- a/rebar.config +++ b/rebar.config @@ -98,6 +98,7 @@ {vmq_diversity, load}, {vmq_webhooks, load}, {vmq_events_sidecar, load}, + {vmq_metrics_plus, load}, {vmq_proto, load}, {vmq_swc, load}, {vmq_pulse, load}, From 775d7f1401c0b4d7ccefbc362b79479730dbfa21 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Wed, 27 Mar 2024 16:15:42 +0530 Subject: [PATCH 02/11] ref: add plugin metrics with pluggable_metrics --- .../src/vmq_metrics_plus.app.src | 1 + .../vmq_metrics_plus/src/vmq_metrics_plus.erl | 23 ++++--------------- apps/vmq_server/src/vmq_metrics.erl | 5 ++-- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src b/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src index 02ac085d3..d33af1b52 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.app.src @@ -9,6 +9,7 @@ lager ]}, {env, [ + {vmq_metrics_mfa, {vmq_metrics_plus, metrics, []}}, {vmq_plugin_hooks, [ {vmq_metrics_plus_plugin, on_subscribe, 3, []}, {vmq_metrics_plus_plugin, on_publish, 7, []}, diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl index 30c442bf5..ecae45bc3 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl @@ -49,21 +49,15 @@ start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). -metrics() -> - {TopicMetricsDefs, TopicMetricsValues} = topic_metrics(), - MetricDefs = TopicMetricsDefs, - MetricValues = TopicMetricsValues, - {MetricDefs, MetricValues}. +metrics() -> topic_metrics(). topic_metrics() -> ets:foldl( - fun({Metric, TotalCount}, {DefsAcc, ValsAcc}) -> + fun({Metric, TotalCount}, Acc) -> {UniqueId, MetricName, Description, Labels} = topic_metric_name(Metric), - {[m(counter, Labels, UniqueId, MetricName, Description) | DefsAcc], [ - {UniqueId, TotalCount} | ValsAcc - ]} + [{counter, Labels, UniqueId, MetricName, Description, TotalCount} | Acc] end, - {[], []}, + [], ?TOPIC_LABEL_TABLE ). @@ -120,15 +114,6 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== -m(Type, Labels, UniqueId, Name, Description) -> - #metric_def{ - type = Type, - labels = Labels, - id = UniqueId, - name = Name, - description = Description - }. - topic_metric_name({Metric, SubMetric, Labels}) -> LMetric = atom_to_list(Metric), LSubMetric = atom_to_list(SubMetric), diff --git a/apps/vmq_server/src/vmq_metrics.erl b/apps/vmq_server/src/vmq_metrics.erl index 533bfb365..e7376f9cd 100644 --- a/apps/vmq_server/src/vmq_metrics.erl +++ b/apps/vmq_server/src/vmq_metrics.erl @@ -441,14 +441,13 @@ metrics(Opts) -> {HistogramMetricDefs, HistogramMetricValues} = histogram_metrics(), {EventsSamplingMetricsDefs, EventsSamplingMetricsValues} = events_sampling_metrics(), {ConfigVersionMetricsDefs, ConfigVersionMetricsValues} = config_version_metrics(), - {PluginMetricDef, PluginMetricValues} = vmq_metrics_plus:metrics(), MetricDefs = metric_defs() ++ PluggableMetricDefs ++ HistogramMetricDefs ++ - EventsSamplingMetricsDefs ++ ConfigVersionMetricsDefs ++ PluginMetricDef, + EventsSamplingMetricsDefs ++ ConfigVersionMetricsDefs, MetricValues = metric_values() ++ PluggableMetricValues ++ HistogramMetricValues ++ - EventsSamplingMetricsValues ++ ConfigVersionMetricsValues ++ PluginMetricValues, + EventsSamplingMetricsValues ++ ConfigVersionMetricsValues, %% Create id->metric def map IdDef = lists:foldl( From 6b5226be691cbac608d9d97e36dd8e8aaee3be65 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Thu, 28 Mar 2024 15:54:26 +0530 Subject: [PATCH 03/11] fix: event-sidecar on_deliver hook to allow next plugin --- apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl b/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl index 28bde34ec..adc80d9f0 100644 --- a/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl +++ b/apps/vmq_events_sidecar/src/vmq_events_sidecar_plugin.erl @@ -312,7 +312,8 @@ on_deliver( {MP, ClientId, normalise(UserName), QoS, unword(Topic), Payload, IsRetain, MatchedAcl, Persisted}, ACL - ). + ), + next. -spec on_delivery_complete( username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() From c9f47fff066dcfdbb7e531a4d15b46935aa1a599 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Sun, 31 Mar 2024 22:38:21 +0530 Subject: [PATCH 04/11] chore: return type hooks to ok and update test cases --- .../test/vmq_events_sidecar_SUITE.erl | 10 ++++++---- apps/vmq_metrics_plus/src/vmq_metrics_plus.erl | 1 - .../src/vmq_metrics_plus_plugin.erl | 17 ++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl b/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl index 0d4017588..9cd39baac 100644 --- a/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl +++ b/apps/vmq_events_sidecar/test/vmq_events_sidecar_SUITE.erl @@ -20,6 +20,7 @@ init_per_suite(Config) -> application:load(vmq_plugin), application:ensure_all_started(vmq_plugin), ok = vmq_plugin_mgr:enable_plugin(vmq_events_sidecar), + ok = vmq_plugin_mgr:enable_plugin(vmq_metrics_plus), {ok, _} = vmq_metrics:start_link(), {ok, _} = application:ensure_all_started(shackle), @@ -30,6 +31,7 @@ end_per_suite(Config) -> stop_tcp_server(proplists:get_value(socket, Config, [])), ok = vmq_plugin_mgr:disable_plugin(vmq_events_sidecar), + ok = vmq_plugin_mgr:disable_plugin(vmq_metrics_plus), application:stop(vmq_plugin), application:stop(shackle), @@ -84,7 +86,7 @@ on_register_empty_properties_test(_) -> on_publish_test(_) -> enable_hook(on_publish), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_publish, + [ok,ok] = vmq_plugin:all(on_publish, [Self, {?MOUNTPOINT, ?ALLOWED_CLIENT_ID}, 1, ?TOPIC, ?PAYLOAD, false, #matched_acl{name = ?LABEL, pattern = ?PATTERN}]), ok = exp_response(on_publish_ok), disable_hook(on_publish). @@ -92,7 +94,7 @@ on_publish_test(_) -> on_subscribe_test(_) -> enable_hook(on_subscribe), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_subscribe, + [ok,ok] = vmq_plugin:all(on_subscribe, [Self, {?MOUNTPOINT, ?ALLOWED_CLIENT_ID}, [{?TOPIC, 1, #matched_acl{name = ?LABEL, pattern = ?PATTERN}}, {?TOPIC, not_allowed, #matched_acl{}}]]), ok = exp_response(on_subscribe_ok), @@ -117,7 +119,7 @@ on_deliver_test(_) -> on_delivery_complete_test(_) -> enable_hook(on_delivery_complete), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_delivery_complete,[Self, {?MOUNTPOINT, ?ALLOWED_CLIENT_ID}, 1, ?TOPIC, ?PAYLOAD, false, #matched_acl{name = ?LABEL, pattern = ?PATTERN}, true]), + [ok,ok] = vmq_plugin:all(on_delivery_complete,[Self, {?MOUNTPOINT, ?ALLOWED_CLIENT_ID}, 1, ?TOPIC, ?PAYLOAD, false, #matched_acl{name = ?LABEL, pattern = ?PATTERN}, true]), ok = exp_response(on_delivery_complete_ok), disable_hook(on_delivery_complete). @@ -159,7 +161,7 @@ on_session_expired_test(_) -> on_message_drop_test(_) -> enable_hook(on_message_drop), Self = pid_to_bin(self()), - [ok] = vmq_plugin:all(on_message_drop, [{?MOUNTPOINT, Self}, fun() -> {?TOPIC, 1, ?PAYLOAD, #{}, #matched_acl{name = ?LABEL, pattern = ?PATTERN}} end, binary_to_atom(?MESSAGE_DROP_REASON)]), + [ok,ok] = vmq_plugin:all(on_message_drop, [{?MOUNTPOINT, Self}, fun() -> {?TOPIC, 1, ?PAYLOAD, #{}, #matched_acl{name = ?LABEL, pattern = ?PATTERN}} end, binary_to_atom(?MESSAGE_DROP_REASON)]), ok = exp_response(on_message_drop_ok), disable_hook(on_message_drop). diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl index ecae45bc3..4ebdcc030 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl @@ -13,7 +13,6 @@ %% limitations under the License. -module(vmq_metrics_plus). --include_lib("apps/vmq_server/src/vmq_metrics.hrl"). -behaviour(gen_server). diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl index d86a6c516..ec1bef098 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl @@ -42,7 +42,7 @@ stop() -> %%%=================================================================== %% called as an all_till_ok hook %% --spec on_subscribe(username(), subscriber_id(), [{topic(), qos(), matched_acl()}]) -> 'next'. +-spec on_subscribe(username(), subscriber_id(), [{topic(), qos(), matched_acl()}]) -> 'ok'. on_subscribe(_UserName, _SubscriberId, Topics) -> lists:foreach( fun(T) -> @@ -50,14 +50,13 @@ on_subscribe(_UserName, _SubscriberId, Topics) -> vmq_metrics_plus:incr_matched_topic(Name, subscribe, QoS) end, Topics - ), - next. + ). -spec on_publish(username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl()) -> - 'next'. + 'ok'. on_publish(_UserName, _SubscriberId, QoS, _Topic, _Payload, _IsRetain, #matched_acl{name = Name}) -> vmq_metrics_plus:incr_matched_topic(Name, publish, QoS), - next. + ok. -spec on_deliver( username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() @@ -74,12 +73,12 @@ on_deliver( _Persisted ) -> vmq_metrics_plus:incr_matched_topic(Name, deliver, QoS), - next. + ok. -spec on_delivery_complete( username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() ) -> - 'next'. + 'ok'. on_delivery_complete( _UserName, _SubscriberId, @@ -91,14 +90,14 @@ on_delivery_complete( _Persisted ) -> vmq_metrics_plus:incr_matched_topic(Name, delivery_complete, QoS), - next. + ok. -spec on_message_drop(subscriber_id(), fun(), reason()) -> 'next'. on_message_drop(SubscriberId, Fun, Reason) -> case Fun() of {_Topic, QoS, _Payload, _Props, #matched_acl{name = Name}} -> vmq_metrics_plus:incr_matched_topic(Name, message_drop, QoS), - next; + ok; _ -> lager:error("unexpected pattern in on_message_drop hook for ~p due to reason ~p", [ SubscriberId, Reason From 5ce146185e34f5d6111d7e946cc37928538da364 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Fri, 5 Apr 2024 16:39:35 +0530 Subject: [PATCH 05/11] ref: rebar config to not load extranal plugin into release --- rebar.config | 3 --- 1 file changed, 3 deletions(-) diff --git a/rebar.config b/rebar.config index 9bf9e0136..522551938 100644 --- a/rebar.config +++ b/rebar.config @@ -91,14 +91,11 @@ {plumtree, load}, {vmq_generic_msg_store, load}, {vmq_generic_offline_msg_store, load}, - {vmq_enhanced_auth, load}, {vmq_passwd, load}, {vmq_acl, load}, {vmq_bridge, load}, {vmq_diversity, load}, {vmq_webhooks, load}, - {vmq_events_sidecar, load}, - {vmq_metrics_plus, load}, {vmq_proto, load}, {vmq_swc, load}, {vmq_pulse, load}, From 66c10ee049ba9f589899b0703a49eee6dec2b311 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Wed, 10 Apr 2024 00:09:00 +0530 Subject: [PATCH 06/11] fix: load jwerl dependency --- rebar.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 522551938..2a14d58bc 100644 --- a/rebar.config +++ b/rebar.config @@ -105,7 +105,8 @@ {runtime_tools, load}, {tools, load}, {mcd, load}, - {vmq_mqtt5_demo_plugin, load} + {vmq_mqtt5_demo_plugin, load}, + {jwerl, load} ]}, % the vars.generated is created by the Makefile From e8fd17041655aa68905154ae314c1183872e28c1 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Wed, 10 Apr 2024 00:25:19 +0530 Subject: [PATCH 07/11] fix: load shackle dependency --- rebar.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 2a14d58bc..5c1a804c8 100644 --- a/rebar.config +++ b/rebar.config @@ -106,7 +106,8 @@ {tools, load}, {mcd, load}, {vmq_mqtt5_demo_plugin, load}, - {jwerl, load} + {jwerl, load}, + {shackle, load} ]}, % the vars.generated is created by the Makefile From 0bdbc9339d2fecb9926d8a968ca87b87658d8fca Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Fri, 12 Apr 2024 11:26:42 +0530 Subject: [PATCH 08/11] chore: remove unnecessary comments --- apps/vmq_metrics_plus/src/vmq_metrics_plus.erl | 1 - apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl | 9 --------- 2 files changed, 10 deletions(-) diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl index 4ebdcc030..facf94710 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus.erl @@ -1,4 +1,3 @@ -%% Copyright 2018 Octavo Labs AG Zurich Switzerland (https://octavolabs.com) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl index 3d170f3cd..41b98a08d 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_sup.erl @@ -19,14 +19,5 @@ start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). -%% sup_flags() = #{strategy => strategy(), % optional -%% intensity => non_neg_integer(), % optional -%% period => pos_integer()} % optional -%% child_spec() = #{id => child_id(), % mandatory -%% start => mfargs(), % mandatory -%% restart => restart(), % optional -%% shutdown => shutdown(), % optional -%% type => worker(), % optional -%% modules => modules()} % optional init([]) -> {ok, {{one_for_one, 5, 10}, [?CHILD(vmq_metrics_plus, worker)]}}. From 2cba4fd6040c2bda7bf7611a7ea16a02c3170713 Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Thu, 18 Apr 2024 00:41:47 +0530 Subject: [PATCH 09/11] fix: sidecar schema translate --- rebar.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rebar.config b/rebar.config index 5c1a804c8..3057bbadb 100644 --- a/rebar.config +++ b/rebar.config @@ -96,6 +96,7 @@ {vmq_bridge, load}, {vmq_diversity, load}, {vmq_webhooks, load}, + {vmq_events_sidecar, load}, {vmq_proto, load}, {vmq_swc, load}, {vmq_pulse, load}, @@ -106,8 +107,7 @@ {tools, load}, {mcd, load}, {vmq_mqtt5_demo_plugin, load}, - {jwerl, load}, - {shackle, load} + {jwerl, load} ]}, % the vars.generated is created by the Makefile From 13fd89f8347bd6e036c437658602636ebad080ae Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Fri, 19 Apr 2024 11:23:12 +0530 Subject: [PATCH 10/11] ref: move events sidecar schema translate to vmq_common --- .../src/vmq_schema_translate.erl} | 2 +- apps/vmq_events_sidecar/priv/vmq_events_sidecar.schema | 4 ++-- rebar.config | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename apps/{vmq_events_sidecar/src/vmq_events_sidecar_schema.erl => vmq_commons/src/vmq_schema_translate.erl} (95%) diff --git a/apps/vmq_events_sidecar/src/vmq_events_sidecar_schema.erl b/apps/vmq_commons/src/vmq_schema_translate.erl similarity index 95% rename from apps/vmq_events_sidecar/src/vmq_events_sidecar_schema.erl rename to apps/vmq_commons/src/vmq_schema_translate.erl index bdde60550..564ad5796 100644 --- a/apps/vmq_events_sidecar/src/vmq_events_sidecar_schema.erl +++ b/apps/vmq_commons/src/vmq_schema_translate.erl @@ -1,4 +1,4 @@ --module(vmq_events_sidecar_schema). +-module(vmq_schema_translate). -export([ translate_sampling/2 diff --git a/apps/vmq_events_sidecar/priv/vmq_events_sidecar.schema b/apps/vmq_events_sidecar/priv/vmq_events_sidecar.schema index 484144794..22827ee97 100644 --- a/apps/vmq_events_sidecar/priv/vmq_events_sidecar.schema +++ b/apps/vmq_events_sidecar/priv/vmq_events_sidecar.schema @@ -60,7 +60,7 @@ {translation, "vmq_events_sidecar.sampler.on_publish", fun(Conf) -> - vmq_events_sidecar_schema:translate_sampling("on_publish", Conf) + vmq_schema_translate:translate_sampling("on_publish", Conf) end }. @@ -70,6 +70,6 @@ {translation, "vmq_events_sidecar.sampler.on_deliver", fun(Conf) -> - vmq_events_sidecar_schema:translate_sampling("on_deliver", Conf) + vmq_schema_translate:translate_sampling("on_deliver", Conf) end }. diff --git a/rebar.config b/rebar.config index 3057bbadb..5c1a804c8 100644 --- a/rebar.config +++ b/rebar.config @@ -96,7 +96,6 @@ {vmq_bridge, load}, {vmq_diversity, load}, {vmq_webhooks, load}, - {vmq_events_sidecar, load}, {vmq_proto, load}, {vmq_swc, load}, {vmq_pulse, load}, @@ -107,7 +106,8 @@ {tools, load}, {mcd, load}, {vmq_mqtt5_demo_plugin, load}, - {jwerl, load} + {jwerl, load}, + {shackle, load} ]}, % the vars.generated is created by the Makefile From dfc5a35c4f822eda164be63b86d338c21302e39b Mon Sep 17 00:00:00 2001 From: Vivek Pipaliya Date: Mon, 29 Apr 2024 10:41:37 +0530 Subject: [PATCH 11/11] ref: on_deliver spec to return ok --- apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl index ec1bef098..f14b5b293 100644 --- a/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl +++ b/apps/vmq_metrics_plus/src/vmq_metrics_plus_plugin.erl @@ -60,8 +60,7 @@ on_publish(_UserName, _SubscriberId, QoS, _Topic, _Payload, _IsRetain, #matched_ -spec on_deliver( username(), subscriber_id(), qos(), topic(), payload(), flag(), matched_acl(), flag() -) -> - 'next' | 'ok' | {'ok', payload() | [on_deliver_hook:msg_modifier()]}. +) -> 'ok'. on_deliver( _UserName, _SubscriberId,