Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only calculate Mnesia memory/table size metrics when enabled #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions src/collectors/mnesia/prometheus_mnesia_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@
%% Type: gauge.<br/>
%% Total number of bytes allocated by all mnesia tables.
%% </li>
%% <li>
%% `erlang_mnesia_tablewise_memory_usage_bytes'<br/>
%% Type: gauge.<br/>
%% Number of bytes allocated per mnesia table
%% </li>
%% <li>
%% `erlang_mnesia_tablewise_size'<br/>
%% Type: gauge.<br/>
%% Number of rows present per table
%% </li>
%% </ul>
%%
%% ==Configuration==
%%
%% Metrics exported by this collector can be configured via
%% `mnesia_collector_metrics' key of `prometheus' app environment.
%%
%% Available options:
%% - `held_locks' for `erlang_mnesia_held_locks';
%% - `lock_queue' for `erlang_mnesia_lock_queue';
%% - `transaction_participants' for `erlang_mnesia_transaction_participants';
%% - `transaction_coordinators' for `erlang_mnesia_transaction_coordinators';
%% - `transaction_failures' for `erlang_mnesia_failed_transactions';
%% - `transaction_commits' for `erlang_mnesia_committed_transactions';
%% - `transaction_log_writes' for `erlang_mnesia_logged_transactions';
%% - `transaction_restarts' for `erlang_mnesia_restarted_transactions';
%% - `memory_usage_bytes' for `erlang_mnesia_memory_usage_bytes'.
%% Remove the `erlang_mnesia_' prefix from the metric name when listing.
%% For example list `held_locks' to enable `erlang_mnesia_held_locks'.
%%
%% By default all metrics are enabled.
%%
Expand Down Expand Up @@ -121,9 +123,6 @@ add_metric_family({Name, Type, Help, Metrics}, Callback) ->

metrics(EnabledMetrics) ->
{Participants, Coordinators} = get_tm_info(EnabledMetrics),
MemoryUsage = get_memory_usage(),
TablewiseMemoryUsage = get_tablewise_memory_usage(),
TablewiseSize = get_tablewise_size(),

[{held_locks, gauge,
"Number of held locks.",
Expand Down Expand Up @@ -151,13 +150,13 @@ metrics(EnabledMetrics) ->
fun() -> mnesia:system_info(transaction_restarts) end},
{memory_usage_bytes, gauge,
"Total number of bytes allocated by all mnesia tables",
fun() -> MemoryUsage end},
fun() -> get_memory_usage() end},
{tablewise_memory_usage_bytes, gauge,
"Number of bytes allocated per mnesia table",
fun() -> TablewiseMemoryUsage end},
fun() -> get_tablewise_memory_usage() end},
{tablewise_size, gauge,
"Number of rows present per table",
fun() -> TablewiseSize end}
fun() -> get_tablewise_size() end}
].

%%====================================================================
Expand Down