From 7c82e5e554b286d20dddb73c2e043a113a161356 Mon Sep 17 00:00:00 2001 From: "John R. Daily" Date: Thu, 28 Aug 2014 10:09:49 -0400 Subject: [PATCH 1/6] Do not treat errors as success --- src/riak_api_ssl.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/riak_api_ssl.erl b/src/riak_api_ssl.erl index 5c073ae..5aa8908 100644 --- a/src/riak_api_ssl.erl +++ b/src/riak_api_ssl.erl @@ -87,8 +87,10 @@ validate_function(Cert, valid, {TrustedCAs, IntermediateCerts}=State) -> [riak_core_ssl_util:get_common_name(Cert), Res]), {Res, {TrustedCAs, [Cert|IntermediateCerts]}} end; -validate_function(_Cert, _Event, State) -> - {valid, State}. +validate_function(_,{bad_cert, _} = Reason, _) -> + {fail, Reason}; +validate_function(_,{extension, _}, UserState) -> + {unknown, UserState}. %% @doc Given a certificate, find CRL distribution points for the given %% certificate, fetch, and attempt to validate each CRL through From f6aac8fc653827ac2082bb38fa1f40b706613dbb Mon Sep 17 00:00:00 2001 From: Jared Morrow Date: Thu, 4 Sep 2014 16:13:31 -0600 Subject: [PATCH 2/6] Set rebar.config deps back to 2.0 branches --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 9dc151e..78f0ad6 100644 --- a/rebar.config +++ b/rebar.config @@ -4,7 +4,7 @@ {deps, [ {riak_pb, "2.0.0.16", {git, "git://github.com/basho/riak_pb.git", {tag, "2.0.0.16"}}}, {webmachine, "1.10.5", {git, "git://github.com/basho/webmachine.git", {tag, "1.10.5"}}}, - {riak_core, ".*", {git, "git://github.com/basho/riak_core.git", {tag, "2.0.0"}}} + {riak_core, ".*", {git, "git://github.com/basho/riak_core.git", {branch, "2.0"}}} ]}. {xref_checks, [undefined_function_calls]}. From 4d10c83ebed7c178fe5a32657e8be11dfd616b45 Mon Sep 17 00:00:00 2001 From: "John R. Daily" Date: Thu, 18 Sep 2014 14:28:31 -0400 Subject: [PATCH 3/6] Be more explicit about bindings we do not need, and tweak horizontal whitespace --- src/riak_api_ssl.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riak_api_ssl.erl b/src/riak_api_ssl.erl index 5aa8908..8f33352 100644 --- a/src/riak_api_ssl.erl +++ b/src/riak_api_ssl.erl @@ -87,9 +87,9 @@ validate_function(Cert, valid, {TrustedCAs, IntermediateCerts}=State) -> [riak_core_ssl_util:get_common_name(Cert), Res]), {Res, {TrustedCAs, [Cert|IntermediateCerts]}} end; -validate_function(_,{bad_cert, _} = Reason, _) -> +validate_function(_Cert, {bad_cert, _} = Reason, _UserState) -> {fail, Reason}; -validate_function(_,{extension, _}, UserState) -> +validate_function(_Cert, {extension, _}, UserState) -> {unknown, UserState}. %% @doc Given a certificate, find CRL distribution points for the given From f6e76aeac47428f12f0f41bf5da37ff349c02867 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Mon, 17 Nov 2014 17:42:51 +0100 Subject: [PATCH 4/6] Exometer metrics in 2.0 --- Makefile | 3 +++ src/riak_api_stat.erl | 33 +++++++++------------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 4e95175..8b9e9ab 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ .PHONY: deps +EXOMETER_PACKAGES = "(basic), +afunix" +export EXOMETER_PACKAGES + all: compile deps: diff --git a/src/riak_api_stat.erl b/src/riak_api_stat.erl index 3dff711..7449302 100644 --- a/src/riak_api_stat.erl +++ b/src/riak_api_stat.erl @@ -28,7 +28,7 @@ produce_stats/0, update/1, stats/0, - active_pb_connects/0]). + active_pb_connects/1]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -45,18 +45,13 @@ start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). register_stats() -> - _ = [(catch folsom_metrics:delete_metric({?APP, Name})) || {Name, _Type} <- stats()], - _ = [register_stat(stat_name(Stat), Type) || {Stat, Type} <- stats()], - riak_core_stat_cache:register_app(?APP, {?MODULE, produce_stats, []}). + riak_core_stat:register_stats(?APP, stats()). %% @doc Return current aggregation of all stats. -spec get_stats() -> proplists:proplist(). get_stats() -> - case riak_core_stat_cache:get_stats(?APP) of - {ok, Stats, _TS} -> - Stats; - Error -> Error - end. + {ok, Stats, _} = riak_core_stat_cache:get_stats(?APP), + Stats. produce_stats() -> {?APP, riak_core_stat_q:get_stats([riak_api])}. @@ -91,7 +86,7 @@ code_change(_OldVsn, State, _Extra) -> %% @doc Update the given `Stat'. -spec update1(term()) -> ok. update1(pbc_connect) -> - folsom_metrics:notify_existing_metric({?APP, pbc_connects}, 1, spiral). + exometer:update([riak_core_stat:prefix(), ?APP, pbc_connects], 1). %% ------------------------------------------------------------------- %% Private @@ -103,21 +98,11 @@ stats() -> {function, ?MODULE, active_pb_connects}} ]. -stat_name(Name) when is_list(Name) -> - list_to_tuple([?APP] ++ Name); -stat_name(Name) when is_atom(Name) -> - {?APP, Name}. - -register_stat(Name, spiral) -> - folsom_metrics:new_spiral(Name); -register_stat(Name, {function, _Module, _Function}=Fun) -> - ok = folsom_metrics:new_gauge(Name), - folsom_metrics:notify({Name, Fun}). - -active_pb_connects() -> +active_pb_connects(_) -> %% riak_api_pb_sup will not be running when there are no listeners %% defined. case erlang:whereis(riak_api_pb_sup) of - undefined -> 0; - _ -> proplists:get_value(active, supervisor:count_children(riak_api_pb_sup)) + undefined -> [{value, 0}]; + _ -> + [{value, proplists:get_value(active, supervisor:count_children(riak_api_pb_sup), 0)}] end. From 0bc9bf58e4e5c0bc666e15f26ee6a93ff861b4f5 Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Wed, 19 Nov 2014 19:16:33 +0100 Subject: [PATCH 5/6] Remove afunix from EXOMETER_PACKAGES. Afunix is not used at this time, and may cause build issues on some platforms. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8b9e9ab..4136208 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: deps -EXOMETER_PACKAGES = "(basic), +afunix" +EXOMETER_PACKAGES = "(basic)" export EXOMETER_PACKAGES all: compile From d443b8e553ff74290640632cf2c434590b14951f Mon Sep 17 00:00:00 2001 From: Ulf Wiger Date: Tue, 25 Nov 2014 15:36:24 +0100 Subject: [PATCH 6/6] Remove exometer instructions from Makefile add aliases together with new stats --- Makefile | 3 --- src/riak_api_stat.erl | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4136208..4e95175 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,5 @@ .PHONY: deps -EXOMETER_PACKAGES = "(basic)" -export EXOMETER_PACKAGES - all: compile deps: diff --git a/src/riak_api_stat.erl b/src/riak_api_stat.erl index 7449302..1ad67cc 100644 --- a/src/riak_api_stat.erl +++ b/src/riak_api_stat.erl @@ -93,9 +93,9 @@ update1(pbc_connect) -> %% ------------------------------------------------------------------- stats() -> [ - {pbc_connects, spiral}, - {[pbc_connects, active], - {function, ?MODULE, active_pb_connects}} + {pbc_connects, spiral, [], [{one, pbc_connects}, + {count, pbc_connects_total}]}, + {[pbc_connects, active], {function, ?MODULE, active_pb_connects}, [], [{value, pbc_active}]} ]. active_pb_connects(_) ->