refactor(prom): unify function name to avoid multiple levels call

This commit is contained in:
JimMoen 2024-05-23 20:09:14 +08:00
parent 065411c69c
commit b91ecac168
No known key found for this signature in database
1 changed files with 16 additions and 15 deletions

View File

@ -295,18 +295,18 @@ fetch_cluster_consistented_data() ->
aggre_or_zip_init_acc() ->
(maybe_add_ds_meta())#{
stats_data => maps:from_keys(metrics_name(stats_metric_meta()), []),
vm_data => maps:from_keys(metrics_name(vm_metric_meta()), []),
cluster_data => maps:from_keys(metrics_name(cluster_metric_meta()), []),
emqx_packet_data => maps:from_keys(metrics_name(emqx_packet_metric_meta()), []),
emqx_message_data => maps:from_keys(metrics_name(message_metric_meta()), []),
emqx_delivery_data => maps:from_keys(metrics_name(delivery_metric_meta()), []),
emqx_client_data => maps:from_keys(metrics_name(client_metric_meta()), []),
emqx_session_data => maps:from_keys(metrics_name(session_metric_meta()), []),
emqx_olp_data => maps:from_keys(metrics_name(olp_metric_meta()), []),
emqx_acl_data => maps:from_keys(metrics_name(acl_metric_meta()), []),
emqx_authn_data => maps:from_keys(metrics_name(authn_metric_meta()), []),
mria_data => maps:from_keys(metrics_name(mria_metric_meta()), [])
stats_data => meta_to_init_from(stats_metric_meta()),
vm_data => meta_to_init_from(vm_metric_meta()),
cluster_data => meta_to_init_from(cluster_metric_meta()),
emqx_packet_data => meta_to_init_from(emqx_packet_metric_meta()),
emqx_message_data => meta_to_init_from(message_metric_meta()),
emqx_delivery_data => meta_to_init_from(delivery_metric_meta()),
emqx_client_data => meta_to_init_from(client_metric_meta()),
emqx_session_data => meta_to_init_from(session_metric_meta()),
emqx_olp_data => meta_to_init_from(olp_metric_meta()),
emqx_acl_data => meta_to_init_from(acl_metric_meta()),
emqx_authn_data => meta_to_init_from(authn_metric_meta()),
mria_data => meta_to_init_from(mria_metric_meta())
}.
logic_sum_metrics() ->
@ -662,9 +662,7 @@ maybe_add_ds_meta() ->
case emqx_persistent_message:is_persistence_enabled() of
true ->
#{
ds_data => maps:from_keys(
metrics_name(emqx_ds_builtin_metrics:prometheus_meta()), []
)
ds_data => meta_to_init_from(emqx_ds_builtin_metrics:prometheus_meta())
};
false ->
#{}
@ -1130,6 +1128,9 @@ zip_json_prom_stats_metrics(Key, Points, AllResultedAcc) ->
ThisKeyResult = lists:foldl(emqx_prometheus_cluster:point_to_map_fun(Key), [], Points),
lists:zipwith(fun maps:merge/2, AllResultedAcc, ThisKeyResult).
meta_to_init_from(Meta) ->
maps:from_keys(metrics_name(Meta), []).
metrics_name(MetricsAll) ->
[Name || {Name, _, _} <- MetricsAll].