Skip to content
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
37 changes: 30 additions & 7 deletions apps/arweave/src/ar_metrics_collector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,11 @@ add_metric_family({Name, Type, Help, Metrics}, Callback) ->
Callback(create_mf(?METRIC_NAME(Name), Help, Type, Metrics)).

metrics() ->
RanchInfo = ranch:info(),
Comment thread
humaite marked this conversation as resolved.
[
{storage_blocks_stored, gauge,
"Blocks stored",
case ets:lookup(ar_header_sync, synced_blocks) of [] -> 0; [{_, N}] -> N end},
{arnode_queue_len, gauge,
"Size of message queuee on ar_node_worker",
element(2, erlang:process_info(whereis(ar_node_worker), message_queue_len))},
{arbridge_queue_len, gauge,
"Size of message queuee on ar_bridge",
element(2, erlang:process_info(whereis(ar_bridge), message_queue_len))},
{ignored_ids_len, gauge,
"Size of table of Ignored/already seen IDs:",
ets:info(ignored_ids, size)},
Expand All @@ -56,7 +51,13 @@ metrics() ->
{ar_header_sync_bytes_total, gauge, "ar_header_sync process memory",
get_process_memory(ar_header_sync)},
{ar_wallets_bytes_total, gauge, "ar_wallets process memory",
get_process_memory(ar_wallets)}
get_process_memory(ar_wallets)},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this long predates your PR (and even predates my time on the project), But I think we can remove all of the message_queue_len and process memory metrics. Unles @humaite you use them for something?

We currently track process memory and message queue length for all processes (not just the ones mentioned here) via the ar_process_sampler module (when debug is on).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem on my side. I'm currently also working on another tool to extract more information regarding all processes. I think we can remove it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it. If we are updating this module, might as well.

{ar_http_iface_listener_ranch_active_connections, gauge, "Currently active Ranch connections",
get_ranch_active_connections(RanchInfo, ar_http_iface_listener)},
{ar_http_iface_listener_ranch_all_connections, gauge, "Currently active Ranch connections",
get_ranch_all_connections(RanchInfo, ar_http_iface_listener)},
{ar_http_iface_listener_ranch_acceptors, gauge, "Currenly live Ranch acceptor processes",
get_ranch_acceptors(ar_http_iface_listener)}
].

get_process_memory(Name) ->
Expand All @@ -67,3 +68,25 @@ get_process_memory(Name) ->
{memory, Memory} = erlang:process_info(PID, memory),
Memory
end.

get_ranch_active_connections(RInfo, Name) ->
get_ranch_info_value(RInfo, Name, active_connections).

get_ranch_all_connections(RInfo, Name) ->
get_ranch_info_value(RInfo, Name, all_connections).

get_ranch_info_value(RInfo, Name, Key) ->
PoolDetails = proplists:get_value(Name, RInfo, []),
%% Signal error condition with -1
proplists:get_value(Key, PoolDetails, -1).

get_ranch_acceptors(Name) ->
Sups = ranch_server:get_listener_sups(),
ListenerSup = proplists:get_value(Name, Sups),
ListenerChildren = supervisor:which_children(ListenerSup),
case lists:keyfind(ranch_acceptors_sup, 1, ListenerChildren) of
{_, AcceptorsSup, _, _} when is_pid(AcceptorsSup) ->
length(supervisor:which_children(AcceptorsSup));
{_, _Atom, _, _} ->
-1
end.
Loading