Permalink
Browse files

Merge pull request #4 from lpgauth/0abe51a99221576cf8b9637dde7faa25b2…

…77abd3

Add messages in queues metric
  • Loading branch information...
2 parents 0fa940d + 0abe51a commit 002b085cb1db694429f4c7f8a5b6a645ce9e1851 @ferd committed Nov 26, 2012
Showing with 17 additions and 0 deletions.
  1. +15 −0 src/vmstats_server.erl
  2. +2 −0 test/vmstats_server_tests.erl
View
@@ -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),
@@ -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 002b085

Please sign in to comment.