Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: basho/riak_kv
base: develop
...
head fork: russelldb/riak_kv
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 10, 2012
@russelldb russelldb Try folsom direct fb1f738
Commits on May 11, 2012
@russelldb russelldb Add call to get_stats from folsom 310cdb5
View
3  src/riak_kv_app.erl
@@ -79,6 +79,9 @@ start(_Type, _StartArgs) ->
%% the app is missing or packaging is broken.
catch cluster_info:register_app(riak_kv_cinfo),
+ %% register all stats
+ riak_kv_stat:register_stats(),
+
%% Spin up supervisor
case riak_kv_sup:start_link() of
{ok, Pid} ->
View
10 src/riak_kv_get_fsm.erl
@@ -314,7 +314,7 @@ read_repair(Indices, RepairObj,
riak_kv_vnode:readrepair(RepairPreflist, BKey, RepairObj, ReqId,
StartTime, [{returnbody, false},
{bucket_props, BucketProps}]),
- riak_kv_stat:update(read_repairs).
+ folsom_metrics:notify({read_repairs, 1}).
get_option(Name, Options, Default) ->
@@ -355,9 +355,13 @@ update_stats({ok, Obj}, #state{get_usecs = GetUsecs}) ->
size(riak_object:key(Obj)) +
size(term_to_binary(riak_object:vclock(Obj))) +
lists:sum([size(term_to_binary(MD)) + value_size(Value) || {MD, Value} <- Contents]),
- riak_kv_stat:update({get_fsm, undefined, GetUsecs, NumSiblings, ObjSize});
+ folsom_metrics:notify({node_gets_total, {inc, 1}}),
+ folsom_metrics:notify({get_fsm_time, GetUsecs}),
+ folsom_metrics:notify({node_get_fsm_siblings, NumSiblings}),
+ folsom_metrics:notify({node_get_fsm_objsize, ObjSize});
update_stats(_, #state{get_usecs = GetUsecs}) ->
- riak_kv_stat:update({get_fsm, undefined, GetUsecs, undefined, undefined}).
+ folsom_metrics:notify({node_gets_total, {inc, 1}}),
+ folsom_metrics:notify({get_fsm_time, GetUsecs}).
value_size(Value) when is_binary(Value) -> size(Value);
value_size(Value) -> size(term_to_binary(Value)).
View
4 src/riak_kv_mapper.erl
@@ -64,7 +64,7 @@ init([VNode, Id, QTerm0, MapInputs, PhasePid]) ->
gen_fsm:send_event(PhasePid, {register_mapper, Id, self()}),
QTermFun = xform_link_walk(QTerm0),
{_, _, ReqId} = erlang:now(),
- riak_kv_stat:update(mapper_start),
+ folsom_metrics:notify({mapper_count, {inc, 1}}),
{ok, CacheRef} = riak_kv_mapred_cache:cache_ref(),
CacheKeyBase = generate_cache_key_base(QTermFun(undefined)),
{ok, VM} = reserve_jsvm(QTermFun(undefined)),
@@ -145,7 +145,7 @@ handle_info(_Info, StateName, State) ->
terminate(_Reason, _StateName, #state{vm=VM, id=_Id, vnode=_VNode, reqid=_ReqId, phase=_PhasePid}=_State) ->
release_jsvm(VM),
- riak_kv_stat:update(mapper_end),
+ folsom_metrics:notify({mapper_count, {dec, 1}}),
_Reason.
code_change(_OldVsn, StateName, State, _Extra) ->
View
6 src/riak_kv_pb_socket.erl
@@ -64,7 +64,9 @@ set_socket(Pid, Socket) ->
gen_server2:call(Pid, {set_socket, Socket}).
init([]) ->
- riak_kv_stat:update(pbc_connect),
+ folsom_metrics:notify({pbc_connects_active, {inc, 1}}),
+ folsom_metrics:notify({pbc_connects_total, {inc, 1}}),
+ folsom_metrics:notify({pbc_connects, 1}),
{ok, C} = riak:local_client(),
{ok, #state{client = C}}.
@@ -221,7 +223,7 @@ handle_info(_, State) -> % Ignore any late replies from gen_servers/messages fro
{noreply, State}.
terminate(_Reason, _State) ->
- riak_kv_stat:update(pbc_disconnect),
+ folsom_metrics:notify({pbc_connects_active, {dec, 1}}),
ok.
code_change(_OldVsn, State, _Extra) -> {ok, State}.
View
29 src/riak_kv_put_fsm.erl
@@ -193,7 +193,7 @@ prepare(timeout, StateData0 = #state{from = From, robj = RObj,
Timeout = get_option(timeout, Options, ?DEFAULT_TIMEOUT),
case rpc:call(CoordNode,riak_kv_put_fsm_sup,start_put_fsm,[CoordNode,[From,RObj,Options]],Timeout) of
{ok, _Pid} ->
- riak_kv_stat:update(coord_redir),
+ folsom_metrics:notify({coord_redirs_total, {inc, 1}}),
{stop, normal, StateData0};
{_, Reason} -> % {error,_} or {badrpc,_}
lager:error("Unable to forward put for ~p to ~p - ~p\n",
@@ -415,7 +415,8 @@ finish(timeout, StateData = #state{timing = Timing, reply = Reply}) ->
%% TODO: Improve reporting of timing
%% For now can add debug tracers to view the return from calc_timing
{Duration, _Stages} = calc_timing(Timing),
- riak_kv_stat:update({put_fsm_time, Duration})
+ folsom_metrics:notify({node_puts_total, {inc, 1}}),
+ folsom_metrics:notify({put_fsm_time, Duration})
end,
{stop, normal, StateData};
finish(Reply, StateData = #state{putcore = PutCore}) ->
@@ -616,17 +617,17 @@ invoke_hook(_, _, _, _) ->
decode_precommit({erlang, {Mod, Fun}, Result}) ->
case Result of
fail ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Pre-commit hook ~p:~p failed, no reason given",
[Mod, Fun]),
fail;
{fail, Reason} ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Pre-commit hook ~p:~p failed with reason ~p",
[Mod, Fun, Reason]),
Result;
{'EXIT', Mod, Fun, Class, Exception} ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Problem invoking pre-commit hook ~p:~p -> ~p:~p~n~p",
[Mod,Fun,Class,Exception, erlang:get_stacktrace()]),
{fail, {hook_crashed, {Mod, Fun, Class, Exception}}};
@@ -634,7 +635,7 @@ decode_precommit({erlang, {Mod, Fun}, Result}) ->
try
riak_object:ensure_robject(Obj)
catch _:_ ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Problem invoking pre-commit hook ~p:~p,"
" invalid return ~p",
[Mod, Fun, Result]),
@@ -645,12 +646,12 @@ decode_precommit({erlang, {Mod, Fun}, Result}) ->
decode_precommit({js, JSName, Result}) ->
case Result of
{ok, <<"fail">>} ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Pre-commit hook ~p failed, no reason given",
[JSName]),
fail;
{ok, [{<<"fail">>, Message}]} ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Pre-commit hook ~p failed with reason ~p",
[JSName, Message]),
{fail, Message};
@@ -662,27 +663,27 @@ decode_precommit({js, JSName, Result}) ->
Obj
end;
{error, Error} ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Problem invoking pre-commit hook: ~p", [Error]),
fail
end;
decode_precommit({error, Reason}) ->
- riak_kv_stat:update(precommit_fail),
+ folsom_metrics:notify({precommit_fail, {inc, 1}}),
lager:debug("Problem invoking pre-commit hook: ~p", [Reason]),
{fail, Reason}.
decode_postcommit({erlang, {M,F}, Res}) ->
case Res of
fail ->
- riak_kv_stat:update(postcommit_fail),
+ folsom_metrics:notify({postcommit_fail, {inc, 1}}),
lager:debug("Post-commit hook ~p:~p failed, no reason given",
[M, F]);
{fail, Reason} ->
- riak_kv_stat:update(postcommit_fail),
+ folsom_metrics:notify({postcommit_fail, {inc, 1}}),
lager:debug("Post-commit hook ~p:~p failed with reason ~p",
[M, F, Reason]);
{'EXIT', _, _, Class, Ex} ->
- riak_kv_stat:update(postcommit_fail),
+ folsom_metrics:notify({postcommit_fail, {inc, 1}}),
Stack = erlang:get_stacktrace(),
lager:debug("Problem invoking post-commit hook ~p:~p -> ~p:~p~n~p",
[M, F, Class, Ex, Stack]),
@@ -690,7 +691,7 @@ decode_postcommit({erlang, {M,F}, Res}) ->
_ -> ok
end;
decode_postcommit({error, {invalid_hook_def, Def}}) ->
- riak_kv_stat:update(postcommit_fail),
+ folsom_metrics:notify({postcommit_fail, {inc, 1}}),
lager:debug("Invalid post-commit hook definition ~p", [Def]).
View
50 src/riak_kv_stat.erl
@@ -181,7 +181,7 @@
-behaviour(gen_server2).
%% API
--export([start_link/0, get_stats/0, get_stats/1, update/1]).
+-export([start_link/0, get_stats/0, get_stats/1, update/1, register_stats/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -218,7 +218,7 @@ start_link() ->
%% @spec get_stats() -> proplist()
%% @doc Get the current aggregation of stats.
get_stats() ->
- get_stats(slide:moment()).
+ lists:flatten([{Name, get_stat(Stat)} || {Name, _Type}=Stat <- stats()]).
get_stats(Moment) ->
gen_server2:call(?MODULE, {get_stats, Moment}, infinity).
@@ -317,6 +317,52 @@ legacy_init() ->
postcommit_fail=0,
legacy=true}}.
+register_stats() ->
+ [register_stat(Stat) || Stat <- stats()].
+
+stats() ->
+ [{vnode_gets, meter},
+ {vnode_gets_total, counter},
+ {vnode_puts, meter},
+ {vnode_puts_total, counter},
+ {vnode_index_reads, meter},
+ {vnode_index_reads_total, counter},
+ {vnode_index_writes, meter},
+ {vnode_index_writes_total, counter},
+ {vnode_index_writes_postings, meter},
+ {vnode_index_writes_postings_total, counter},
+ {vnode_index_deletes, meter},
+ {vnode_index_deletes_total, counter},
+ {vnode_index_deletes_postings, meter},
+ {vnode_index_deletes_postings_total, counter},
+ {node_gets_total, counter},
+ {node_get_fsm_siblings, histogram},
+ {node_get_fsm_objsize, histogram},
+ {get_fsm_time, histogram},
+ {node_puts_total, counter},
+ {put_fsm_time, histogram},
+ {pbc_connects, meter},
+ {pbc_connects_total, counter},
+ {pbc_connects_active, counter},
+ {read_repairs, meter},
+ {read_repairs_total, counter},
+ {coord_redirs_total, counter},
+ {mapper_count, counter},
+ {precommit_fail, counter},
+ {postcommit_fail, counter}].
+
+register_stat({Name, meter}) ->
+ folsom_metrics:new_meter(Name);
+register_stat({Name, counter}) ->
+ folsom_metrics:new_counter(Name);
+register_stat({Name, histogram}) ->
+ folsom_metrics:new_histogram(Name).
+
+get_stat({Name, histogram}) ->
+ folsom_metrics:get_histogram_statistics(Name);
+get_stat({Name, _Type}) ->
+ folsom_metrics:get_metric_value(Name).
+
%% @private
handle_call({get_stats, Moment}, _From, State) ->
{reply, produce_stats(State, Moment), State};
View
32 src/riak_kv_vnode.erl
@@ -432,8 +432,8 @@ handle_coverage(?KV_INDEX_REQ{bucket=Bucket,
case IndexBackend of
true ->
%% Update stats...
- riak_kv_stat:update(vnode_index_read),
-
+ folsom_metrics:notify({vnode_index_reads, 1}),
+ folsom_metrics:notify({vnode_index_reads_total, {inc, 1}}),
%% Construct the filter function
FilterVNode = proplists:get_value(Index, FilterVNodes),
Filter = riak_kv_coverage_filter:build_filter(Bucket, ItemFilter, FilterVNode),
@@ -608,7 +608,8 @@ do_put(Sender, {Bucket,_Key}=BKey, RObj, ReqID, StartTime, Options, State) ->
riak_core_vnode:reply(Sender, Reply),
update_index_write_stats(UpdPutArgs#putargs.index_specs),
- riak_kv_stat:update(vnode_put),
+ folsom_metrics:notify({vnode_puts, 1}),
+ folsom_metrics:notify({vnode_puts_total, {inc, 1}}),
UpdState.
do_backend_delete(BKey, RObj, State = #state{mod = Mod, modstate = ModState}) ->
@@ -803,7 +804,8 @@ put_merge(true, false, CurObj, UpdObj, VId, StartTime) ->
do_get(_Sender, BKey, ReqID,
State=#state{idx=Idx,mod=Mod,modstate=ModState}) ->
Retval = do_get_term(BKey, Mod, ModState),
- riak_kv_stat:update(vnode_get),
+ folsom_metrics:notify({vnode_gets, 1}),
+ folsom_metrics:notify({vnode_gets_total, {inc, 1}}),
{reply, {r, Retval, Idx, ReqID}, State}.
do_mget({fsm, Sender}, BKeys, ReqId, State=#state{idx=Idx, mod=Mod, modstate=ModState}) ->
@@ -815,7 +817,9 @@ do_mget({fsm, Sender}, BKeys, ReqId, State=#state{idx=Idx, mod=Mod, modstate=Mod
_ ->
gen_fsm:send_event(Sender, {r, {R, BKey}, Idx, ReqId})
end,
- riak_kv_stat:update(vnode_get) end,
+ folsom_metrics:notify({vnode_gets, 1}),
+ folsom_metrics:notify({vnode_gets_total, {inc, 1}})
+ end,
[F(BKey) || BKey <- BKeys],
{noreply, State}.
@@ -1039,7 +1043,8 @@ do_diffobj_put({Bucket, Key}, DiffObj,
case Res of
{ok, _UpdModState} ->
update_index_write_stats(IndexSpecs),
- riak_kv_stat:update(vnode_put);
+ folsom_metrics:notify({vnode_puts, 1}),
+ folsom_metrics:notify({vnode_puts_total, {inc, 1}});
_ -> nop
end,
Res;
@@ -1064,7 +1069,8 @@ do_diffobj_put({Bucket, Key}, DiffObj,
case Res of
{ok, _UpdModState} ->
update_index_write_stats(IndexSpecs),
- riak_kv_stat:update(vnode_put);
+ folsom_metrics:notify({vnode_puts, 1}),
+ folsom_metrics:notify({vnode_puts_total, {inc, 1}});
_ ->
nop
end,
@@ -1175,12 +1181,20 @@ wait_for_vnode_status_results(PrefLists, ReqId, Acc) ->
%% @private
update_index_write_stats(IndexSpecs) ->
{Added, Removed} = count_index_specs(IndexSpecs),
- riak_kv_stat:update({vnode_index_write, Added, Removed}).
+ folsom_metrics:notify({vnode_index_writes, 1}),
+ folsom_metrics:notify({vnode_index_writes_total, {inc, 1}}),
+ folsom_metrics:notify({vnode_index_writes_postings, Added}),
+ folsom_metrics:notify({vnode_index_writes_postings_total, {inc, Added}}),
+ folsom_metrics:notify({vnode_index_deletes_postings, Removed}),
+ folsom_metrics:notify({vnode_index_deletes_postings_total, {inc, Removed}}).
%% @private
update_index_delete_stats(IndexSpecs) ->
{_Added, Removed} = count_index_specs(IndexSpecs),
- riak_kv_stat:update({vnode_index_delete, Removed}).
+ folsom_metrics:notify({vnode_index_deletes, Removed}),
+ folsom_metrics:notify({vnode_index_deletes_total, {inc, Removed}}),
+ folsom_metrics:notify({vnode_index_deletes_postings, Removed}),
+ folsom_metrics:notify({vnode_index_deletes_postings_total, {inc, Removed}}).
%% @private
%% @doc Given a list of index specs, return the number to add and

No commit comments for this range

Something went wrong with that request. Please try again.