Skip to content
Browse files

Added messages in queues statistic

  • Loading branch information...
1 parent 0fa940d commit 0abe51a99221576cf8b9637dde7faa25b277abd3 @lpgauth lpgauth committed
Showing with 17 additions and 0 deletions.
  1. +15 −0 src/vmstats_server.erl
  2. +2 −0 test/vmstats_server_tests.erl
View
15 src/vmstats_server.erl
@@ -66,6 +66,21 @@ handle_info({timeout, R, ?TIMER_MSG}, S = #state{key=K, delay=D, timer_ref=R}) -
statsderl:gauge([K,"proc_count"], erlang:system_info(process_count), 1.00),
statsderl:gauge([K,"proc_limit"], erlang:system_info(process_limit), 1.00),
+ %% Messages in queues
+ ProcessInfo = lists:flatmap(
+ fun (Pid) ->
+ case process_info(Pid, message_queue_len) of
+ undefined ->
+ [];
+ {message_queue_len, 0} ->
+ [];
+ {message_queue_len, Count} ->
+ [{Count, Pid}]
+ end
+ end, processes()),
+ TotalMessages = lists:sum(element(1, lists:unzip(ProcessInfo))),
+ statsderl:gauge([K,"messages_in_queues"], TotalMessages, 1.00),
+
%% Modules loaded
statsderl:gauge([K,"modules"], length(code:all_loaded()), 1.00),
View
2 test/vmstats_server_tests.erl
@@ -24,6 +24,7 @@ timer_500ms_test() ->
{"key.memory.ets", _, 1.00},
{"key.memory.procs_used", _, 1.00},
{"key.memory.total", _, 1.00},
+ {"key.messages_in_queues", _, 1.00},
{"key.modules", _, 1.00},
{"key.proc_count", _, 1.00},
{"key.proc_limit", _, 1.00},
@@ -45,6 +46,7 @@ timer_500ms_test() ->
{"key.memory.ets", _, 1.00},
{"key.memory.procs_used", _, 1.00},
{"key.memory.total", _, 1.00},
+ {"key.messages_in_queues", _, 1.00},
{"key.modules", _, 1.00},
{"key.proc_count", _, 1.00},
{"key.proc_limit", _, 1.00},

0 comments on commit 0abe51a

Please sign in to comment.
Something went wrong with that request. Please try again.