couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chewbra...@apache.org
Subject couch-stats commit: updated refs/heads/use-notify-existing-metric to 0d7ab07
Date Mon, 17 Aug 2015 19:31:37 GMT
Repository: couchdb-couch-stats
Updated Branches:
  refs/heads/use-notify-existing-metric [created] 0d7ab0743


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/0d7ab074
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/tree/0d7ab074
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/diff/0d7ab074

Branch: refs/heads/use-notify-existing-metric
Commit: 0d7ab074374fd9eab8f157ad197bd49c59c7930a
Parents: a842f3b
Author: Russell Branca <chewbranca@apache.org>
Authored: Fri Aug 14 23:17:46 2015 +0000
Committer: Russell Branca <chewbranca@apache.org>
Committed: Fri Aug 14 23:17:46 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/0d7ab074/src/couch_stats.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats.erl b/src/couch_stats.erl
index d65ea6a..bd2123c 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 _:_ ->
+        twig:log(notice, "unknown metric: ~p", [Name]),
+        {error, unknown_metric}
     end.
 
 -spec sample_type(any(), atom()) -> stat().


Mime
View raw message