couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [29/50] folsom commit: updated refs/heads/import-master to 4824aec
Date Thu, 31 Jul 2014 21:25:17 GMT
wrap erlang:statistics and get_system_info to avoid issues on new/old vms


Project: http://git-wip-us.apache.org/repos/asf/couchdb-folsom/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-folsom/commit/ade45c8a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-folsom/tree/ade45c8a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-folsom/diff/ade45c8a

Branch: refs/heads/import-master
Commit: ade45c8a6edd39e497211900db6f4c4362911dec
Parents: ffc18d2
Author: Joe Williams <joe.williams@github.com>
Authored: Mon Nov 4 11:07:20 2013 -0800
Committer: Joe Williams <joe.williams@github.com>
Committed: Mon Nov 4 11:07:20 2013 -0800

----------------------------------------------------------------------
 src/folsom_vm_metrics.erl | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-folsom/blob/ade45c8a/src/folsom_vm_metrics.erl
----------------------------------------------------------------------
diff --git a/src/folsom_vm_metrics.erl b/src/folsom_vm_metrics.erl
index 8a42f40..fc91d86 100644
--- a/src/folsom_vm_metrics.erl
+++ b/src/folsom_vm_metrics.erl
@@ -46,10 +46,10 @@ get_memory() ->
     erlang:memory().
 
 get_statistics() ->
-    [{Key, convert_statistics({Key, erlang:statistics(Key)})} || Key <- ?STATISTICS].
+    [{Key, convert_statistics({Key, get_statistics(Key)})} || Key <- ?STATISTICS].
 
 get_system_info() ->
-    [{Key, convert_system_info({Key, erlang:system_info(Key)})} || Key <- ?SYSTEM_INFO].
+    [{Key, convert_system_info({Key, get_system_info(Key)})} || Key <- ?SYSTEM_INFO].
 
 get_process_info() ->
     [{pid_port_fun_to_atom(Pid), get_process_info(Pid)} || Pid <- processes()].
@@ -65,6 +65,19 @@ get_dets_info() ->
 
 % internal functions
 
+% wrap system_info and statistics in a try/catch in case keys are missing
+% in old/new versions of erlang
+
+get_system_info(Key) ->
+    try erlang:system_info(Key) catch
+                                    error:badarg->undefined
+                                end.
+
+get_statistics(Key) ->
+    try erlang:statistics(Key) catch
+                                   error:badarg->undefined
+                               end.
+
 %% conversion functions for erlang:statistics(Key)
 
 convert_statistics({context_switches, {ContextSwitches, 0}}) ->


Mime
View raw message