Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Slight optimization of message queue metrics

Also adding to changelog and bumping future app vsn
  • Loading branch information...
commit b1dda46a35d7576d020202185ba150eb8b88d84a 1 parent 002b085
@ferd authored
Showing with 15 additions and 13 deletions.
  1. +4 −0 README.markdown
  2. +1 −1  src/vmstats.app.src
  3. +10 −12 src/vmstats_server.erl
View
4 README.markdown
@@ -33,6 +33,10 @@ You are likely using vmstats with an Erlang release prior to R15B. Switch away f
## CHANGELOG ##
+### 0.2.3 (Upcoming version / master branch) ###
+- Adding messages in queues metric, providing a global count of queued up messages in the system.
+
+
### 0.2.2 ###
- Adding garbage collection count per interval
View
2  src/vmstats.app.src
@@ -1,6 +1,6 @@
{application, vmstats, [
{description, "Tiny application to gather VM statistics for StatsD client"},
- {vsn, "0.2.2"},
+ {vsn, "0.2.3"},
{registered, [vmstats_sup, vmstats_server]},
{applications, [
kernel,
View
22 src/vmstats_server.erl
@@ -67,18 +67,16 @@ handle_info({timeout, R, ?TIMER_MSG}, S = #state{key=K, delay=D, timer_ref=R}) -
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))),
+ TotalMessages = lists:foldl(
+ fun(Pid, Acc) ->
+ case process_info(Pid, message_queue_len) of
+ undefined -> Acc;
+ {message_queue_len, Count} -> Count+Acc
+ end
+ end,
+ 0,
+ processes()
+ ),
statsderl:gauge([K,"messages_in_queues"], TotalMessages, 1.00),
%% Modules loaded
Please sign in to comment.
Something went wrong with that request. Please try again.