Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 387ED11285 for ; Wed, 3 Sep 2014 20:09:33 +0000 (UTC) Received: (qmail 10747 invoked by uid 500); 3 Sep 2014 20:09:33 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 10695 invoked by uid 500); 3 Sep 2014 20:09:33 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 10685 invoked by uid 99); 3 Sep 2014 20:09:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 20:09:33 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B6BD9A06F48; Wed, 3 Sep 2014 20:09:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mikewallace@apache.org To: commits@couchdb.apache.org Message-Id: <2a01437d2a6840aabcb9b8f39e7fb3e3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: couch-stats commit: updated refs/heads/master to ab8d36b Date: Wed, 3 Sep 2014 20:09:32 +0000 (UTC) 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 Authored: Wed Sep 3 20:43:37 2014 +0100 Committer: Mike Wallace 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,