couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject [1/2] couch-stats commit: updated refs/heads/master to 7895d4d
Date Fri, 21 Aug 2015 17:50:54 GMT
Repository: couchdb-couch-stats
Updated Branches:
  refs/heads/master a842f3bc6 -> 7895d4d3f


We already know the metric type, so supply it directly


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/commit/9ba52013
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/tree/9ba52013
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/diff/9ba52013

Branch: refs/heads/master
Commit: 9ba5201399d8b277940d049c3d712e0f5de83c70
Parents: a842f3b
Author: Russell Branca <chewbranca@apache.org>
Authored: Fri Aug 14 23:17:46 2015 +0000
Committer: Russell Branca <chewbranca@apache.org>
Committed: Mon Aug 17 19:48:22 2015 +0000

----------------------------------------------------------------------
 src/couch_stats.erl | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/blob/9ba52013/src/couch_stats.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats.erl b/src/couch_stats.erl
index d65ea6a..e02da29 100644
--- a/src/couch_stats.erl
+++ b/src/couch_stats.erl
@@ -77,19 +77,19 @@ list() ->
 
 -spec increment_counter(any()) -> response().
 increment_counter(Name) ->
-    notify(Name, {inc, 1}).
+    notify_existing_metric(Name, {inc, 1}, counter).
 
 -spec increment_counter(any(), pos_integer()) -> response().
 increment_counter(Name, Value) ->
-    notify(Name, {inc, Value}).
+    notify_existing_metric(Name, {inc, Value}, counter).
 
 -spec decrement_counter(any()) -> response().
 decrement_counter(Name) ->
-    notify(Name, {dec, 1}).
+    notify_existing_metric(Name, {dec, 1}, counter).
 
 -spec decrement_counter(any(), pos_integer()) -> response().
 decrement_counter(Name, Value) ->
-    notify(Name, {dec, Value}).
+    notify_existing_metric(Name, {dec, Value}, counter).
 
 -spec update_histogram(any(), number()) -> response();
                       (any(), function()) -> any().
@@ -97,27 +97,26 @@ update_histogram(Name, Fun) when is_function(Fun, 0) ->
     Begin = os:timestamp(),
     Result = Fun(),
     Duration = timer:now_diff(os:timestamp(), Begin) div 1000,
-    case notify(Name, Duration) of
+    case notify_existing_metric(Name, Duration, histogram) of
         ok ->
             Result;
         {error, unknown_metric} ->
             throw({unknown_metric, Name})
     end;
 update_histogram(Name, Value) when is_number(Value) ->
-    notify(Name, Value).
+    notify_existing_metric(Name, Value, histogram).
 
 -spec update_gauge(any(), number()) -> response().
 update_gauge(Name, Value) ->
-    notify(Name, Value).
-
--spec notify(any(), any()) -> response().
-notify(Name, Op) ->
-    case folsom_metrics:notify(Name, Op) of
-        ok ->
-            ok;
-        _ ->
-            couch_log:notice("unknown metric: ~p", [Name]),
-            {error, unknown_metric}
+    notify_existing_metric(Name, Value, gauge).
+
+-spec notify_existing_metric(any(), any(), any()) -> response().
+notify_existing_metric(Name, Op, Type) ->
+    try
+        ok = folsom_metrics:notify_existing_metric(Name, Op, Type)
+    catch _:_ ->
+        couch_log:notice("unknown metric: ~p", [Name]),
+        {error, unknown_metric}
     end.
 
 -spec sample_type(any(), atom()) -> stat().


Mime
View raw message