You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by mi...@apache.org on 2014/09/03 22:09:32 UTC
couch-stats commit: updated refs/heads/master to ab8d36b
Repository: couchdb-couch-stats
Updated Branches:
refs/heads/master 1c3dae961 -> ab8d36b39
Avoid recreating all metrics on reload
This commit fixes a bug in the comparison of the loaded metrics
and all application metrics. Because the Props for each metric
differ in the output of couch_stats:list/0 and
load_metrics_for_application/0 the set subtraction operations
in reload_metrics/0 would always leave a full set, so all metrics
would be deleted and created on every reload.
This is fixed by ensuring the sets for existing and current
metrics consist of {Name, Type} only.
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/ab8d36b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/tree/ab8d36b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/diff/ab8d36b3
Branch: refs/heads/master
Commit: ab8d36b3973364b3a87f90767b9fadab016ac38b
Parents: 1c3dae9
Author: Mike Wallace <mi...@apache.org>
Authored: Wed Sep 3 20:43:37 2014 +0100
Committer: Mike Wallace <mi...@apache.org>
Committed: Wed Sep 3 21:03:05 2014 +0100
----------------------------------------------------------------------
src/couch_stats_aggregator.erl | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch-stats/blob/ab8d36b3/src/couch_stats_aggregator.erl
----------------------------------------------------------------------
diff --git a/src/couch_stats_aggregator.erl b/src/couch_stats_aggregator.erl
index 456af76..64e7fa9 100644
--- a/src/couch_stats_aggregator.erl
+++ b/src/couch_stats_aggregator.erl
@@ -79,10 +79,14 @@ terminate(_Reason, _State) ->
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+props_to_type({Name, Props}) ->
+ {Name, proplists:get_value(type, Props)}.
+
reload_metrics() ->
- Current = load_metrics_for_applications(),
+ Current = lists:map(fun props_to_type/1, load_metrics_for_applications()),
CurrentSet = sets:from_list(Current),
- ExistingSet = sets:from_list(couch_stats:list()),
+ Existing = lists:map(fun props_to_type/1, couch_stats:list()),
+ ExistingSet = sets:from_list(Existing),
ToDelete = sets:subtract(ExistingSet, CurrentSet),
ToCreate = sets:subtract(CurrentSet, ExistingSet),
sets:fold(
@@ -91,8 +95,7 @@ reload_metrics() ->
ToDelete
),
sets:fold(
- fun({Name, Props}, _) ->
- Type = proplists:get_value(type, Props),
+ fun({Name, Type}, _) ->
couch_stats:new(Type, Name),
nil
end,