Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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: russelldb/riak_kv
...
head fork: russelldb/riak_kv
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 30, 2012
@russelldb Raise level at which vnode metric shows all
Update fsm metric for easier query
23c7beb
Commits on May 03, 2012
@russelldb Produce stats by level f936205
Commits on May 09, 2012
@russelldb Accept lists as spec for value/4 dc5d288
View
15 src/riak_kv_fsm_metric.erl
@@ -79,8 +79,9 @@ value(Level, Name, State) when is_integer(Level) ->
%% Get the value for the level / path
value(Level, [], Name, State) ->
value(Level, Name, State);
-value(_Level, [total|_Rest], Name, State) ->
- value(0, Name, State);
+value(_Level, [total], Name, State) ->
+ [Value] = value(0, Name, State),
+ Value;
value(Level, [buckets|[]], Name, #state{buckets=Buckets}) ->
bucket_values(Level, [], Name, Buckets);
value(Level, [buckets, '*'|Path], Name, #state{buckets=Buckets}) ->
@@ -94,7 +95,7 @@ value(Level, [buckets, Bucket|Path], Name, #state{buckets=Buckets}) ->
error ->
[]
end;
-value(Level, [Histo|[]], Name, State) ->
+value(Level, [Histo], Name, State) when is_atom(Histo) ->
%% the given histo at Level
histogram_value(Histo, Name, State, Level);
value(Level, [Histo, Field], Name, State) ->
@@ -224,9 +225,9 @@ level_value_test_() ->
ok end,
fun({Buckets, NoBuckets}) ->
[
- ?_assertEqual([{stat_total, 0}], riak_kv_fsm_metric:value(1, [total], stat, Buckets)),
- ?_assertEqual([{stat_time_p99, 0}], riak_kv_fsm_metric:value(0, [time, p99], stat, Buckets)),
- ?_assertEqual(histo(stat_objsize, 3), riak_kv_fsm_metric:value(3, [objsize], stat, Buckets)),
+ ?_assertEqual({stat_total, 0}, riak_kv_fsm_metric:value(1, total, stat, Buckets)),
+ ?_assertEqual({stat_time_p99, 0}, riak_kv_fsm_metric:value(0, [time, p99], stat, Buckets)),
+ ?_assertEqual(histo(stat_objsize, 3), riak_kv_fsm_metric:value(3, objsize, stat, Buckets)),
?_assertEqual([], riak_kv_fsm_metric:value(10000000, [peppercorn, quango], stat, Buckets)),
?_assertEqual({stat_buckets, [{<<"A">>, [{'stat_A_total',0}]},
{<<"B">>, [{'stat_B_total',0}]}]},
@@ -239,7 +240,7 @@ level_value_test_() ->
?_assertEqual([{stat_B_total, 0}],
riak_kv_fsm_metric:value(0, [buckets, <<"B">>], stat, Buckets)),
%% deep bucket
- ?_assertEqual([{stat_B_time_p99, 0}],
+ ?_assertEqual({stat_B_time_p99, 0},
riak_kv_fsm_metric:value(0, [buckets, <<"B">>, time, p99], stat, Buckets)),
%% No Buckets
?_assertEqual([], riak_kv_fsm_metric:value(4, [buckets, '*'], stat, NoBuckets)),
View
4 src/riak_kv_index_metric.erl
@@ -65,7 +65,9 @@ value(Level, Name, State) ->
lists:flatten([riak_core_metric_meter:value(Level, stat_name(Name, Field), Stat)
|| {Field, Stat} <- to_proplist(State)]).
-value(Level, Field, Name, State) when is_atom(Field) ->
+value(Level, [], Name, State) ->
+ value(Level, Name, State);
+value(Level, [Field], Name, State) when is_atom(Field) ->
Meter = get_meter(Field, State),
MeterName = stat_name(Name, Field),
riak_core_metric_meter:value(Level, MeterName, Meter);
View
6 src/riak_kv_pb_metric.erl
@@ -47,10 +47,12 @@ value(Level, Name, #state{connects=Conns, active=Active}) ->
ActiveName = riak_core_metric:join_as_atom([Name, '_', active]),
[{ActiveName, Active}|riak_core_metric_meter:value(Level, Name, Conns)].
-value(_Level, active, Name, #state{active=Active}) ->
+value(Level, [], Name, State) ->
+ value(Level, Name, State);
+value(_Level, [active], Name, #state{active=Active}) ->
ActiveName = riak_core_metric:join_as_atom([Name, '_', active]),
[{ActiveName, Active}];
-value(Level, Field, Name, #state{connects=Conns}) ->
+value(Level, [Field], Name, #state{connects=Conns}) ->
riak_core_metric_meter:value(Level, Field, Name, Conns).
tick(#state{connects=Conns}) ->
View
81 src/riak_kv_stat.erl
@@ -183,68 +183,69 @@
-module(riak_kv_stat).
%% API
--export([get_stats/0, update/1]).
+-export([get_stats/0, get_stats/1, update/1]).
%% stats
-export([stat_specs/0]).
-spec stat_specs() -> riak_core_metric:stat_specs().
stat_specs() ->
- [{vnode_gets, [{type, {mod, riak_kv_vnode_metric}}, {group, vnode}]},
- {vnode_puts, [{type, {mod, riak_kv_vnode_metric}}, {group, vnode}]},
- {vnode_index, [{type, {mod, riak_kv_index_metric}}, {group, vnode}]},
- {get_fsm, [{type, {mod, riak_kv_fsm_metric}}, {group, node}]},
- {put_fsm, [{type, {mod, riak_kv_fsm_metric}}, {group, node}]},
- {pbc_connects, [{type, {mod, riak_kv_pb_metric}}, {group, pbc}]},
- {read_repairs, [{type, meter}, {group, node}]},
- {coord_redirs_total, [{type, counter}, {group, node}]},
- {mapper_count, [{type, counter}, {group, mapper}]},
- {precommit_fail, [{type, counter}, {group, node}]},
- {postcommit_fail, [{type, counter}, {group, node}]}
+ [{riak_kv_vnode_gets, [{type, {mod, riak_kv_vnode_metric}}, {group, vnode}]},
+ {riak_kv_vnode_puts, [{type, {mod, riak_kv_vnode_metric}}, {group, vnode}]},
+ {riak_kv_vnode_index, [{type, {mod, riak_kv_index_metric}}, {group, vnode}]},
+ {riak_kv_get_fsm, [{type, {mod, riak_kv_fsm_metric}}, {group, node}]},
+ {riak_kv_put_fsm, [{type, {mod, riak_kv_fsm_metric}}, {group, node}]},
+ {riak_kv_pbc_connects, [{type, {mod, riak_kv_pb_metric}}, {group, pbc}]},
+ {riak_kv_read_repairs, [{type, meter}, {group, node}]},
+ {riak_kv_coord_redirs_total, [{type, counter}, {group, node}]},
+ {riak_kv_mapper_count, [{type, counter}, {group, mapper}]},
+ {riak_kv_precommit_fail, [{type, counter}, {group, node}]},
+ {riak_kv_postcommit_fail, [{type, counter}, {group, node}]}
].
-%% @spec get_stats() -> proplist()
-%% @doc Get the current aggregation of stats.
get_stats() ->
- produce_stats(legacy).
+ produce_stats(5).
+
+get_stats(Level) ->
+ produce_stats(Level).
%% @spec update(term()) -> ok
%% @doc Update the given stat.
update({vnode_get, Vnode}) ->
- riak_core_metric_proc:update(vnode_gets, {1, slide:moment(), Vnode});
+ riak_core_metric_proc:update(riak_kv_vnode_gets, {1, slide:moment(), Vnode});
update({vnode_put, VNode}) ->
- riak_core_metric_proc:update(vnode_puts, {1, slide:moment(), VNode});
+ riak_core_metric_proc:update(riak_kv_vnode_puts, {1, slide:moment(), VNode});
update(vnode_index_read) ->
- riak_core_metric_proc:update(vnode_index, slide:moment());
+ riak_core_metric_proc:update(riak_kv_vnode_index, slide:moment());
update({vnode_index_write, PostingsAdded, PostingsRemoved}) ->
- riak_core_metric_proc:update(vnode_index,
+ riak_core_metric_proc:update(riak_kv_vnode_index,
{PostingsAdded, PostingsRemoved, slide:moment()});
update({vnode_index_delete, Postings}) ->
- riak_core_metric_proc:update(vnode_index, {Postings, slide:moment()});
+ riak_core_metric_proc:update(riak_kv_vnode_index, {Postings, slide:moment()});
update({get_fsm, Bucket, Microsecs, undefined, undefined}) ->
- riak_core_metric_proc:update(get_fsm, {Bucket, Microsecs, slide:moment()});
+ riak_core_metric_proc:update(riak_kv_get_fsm, {Bucket, Microsecs, slide:moment()});
update({get_fsm, Bucket, Microsecs, NumSiblings, ObjSize}) ->
- riak_core_metric_proc:update(get_fsm,
+ riak_core_metric_proc:update(riak_kv_get_fsm,
{Bucket, Microsecs, NumSiblings,
ObjSize, slide:moment()});
update({put_fsm_time, Bucket, Microsecs}) ->
- riak_core_metric_proc:update(put_fsm, {Bucket, Microsecs, slide:moment()});
+ riak_core_metric_proc:update(riak_kv_put_fsm, {Bucket, Microsecs, slide:moment()});
update(pbc_connect) ->
- riak_core_metric_proc:update(pbc_connects, {1, slide:moment()});
+ riak_core_metric_proc:update(riak_kv_pbc_connects, {1, slide:moment()});
update(pbc_disconnect) ->
- riak_core_metric_proc:update(pbc_connects, -1);
+ riak_core_metric_proc:update(riak_kv_pbc_connects, -1);
update(read_repairs) ->
- riak_core_metric_proc:update(read_repairs, {1, slide:moment()});
+ riak_core_metric_proc:update(riak_kv_read_repairs, {1, slide:moment()});
update(coord_redir) ->
- riak_core_metric_proc:update(coord_redirs_total, 1);
+ riak_core_metric_proc:update(riak_kv_coord_redirs_total, 1);
update(mapper_start) ->
- riak_core_metric_proc:update(mapper_count, 1);
+ riak_core_metric_proc:update(riak_kv_mapper_count, 1);
update(mapper_end) ->
- riak_core_metric_proc:update(mapper_count, -1);
+ riak_core_metric_proc:update(riak_kv_mapper_count, -1);
update(precommit_fail) ->
- riak_core_metric_proc:update(precommit_fail, 1);
+ riak_core_metric_proc:update(riak_kv_precommit_fail, 1);
update(postcommit_fail) ->
- riak_core_metric_proc:update(postcommit_fail, 1);
+ riak_core_metric_proc:update(riak_kv_postcommit_fail, 1);
update(Stat) ->
lager:warning("Update called for unkown stat: ~p", [Stat]).
@@ -255,28 +256,28 @@ update(Stat) ->
%% @spec produce_stats(integer()) -> proplist()
%% @doc Produce a proplist-formatted view of the current aggregation
%% of stats.
-produce_stats(Presentation) ->
+produce_stats(Level) ->
lists:append(
- [produce_stats(Presentation, vnode),
- produce_stats(Presentation, node),
- pbc_stats(Presentation),
- produce_stats(Presentation, mapper)
+ [produce_stats(Level, vnode),
+ produce_stats(Level, node),
+ pbc_stats(Level),
+ produce_stats(Level, mapper)
]).
%% @spec pbc_stats(integer(), state()) -> proplist()
%% @doc Get stats on the disk, as given by the disksup module
%% of the os_mon application.
-pbc_stats(Presentation) ->
+pbc_stats(Level) ->
case whereis(riak_kv_pb_socket_sup) of
undefined ->
[];
- _ -> produce_stats(Presentation, pbc)
+ _ -> produce_stats(Level, pbc)
end.
%% @doc produce a proplist for the given Group of stats,
%% formatted for the Given Presentation.
-spec produce_stats(atom(), atom()) -> [{atom(), integer()}].
-produce_stats(Presentation, Group) when is_atom(Presentation), is_atom(Group) ->
- Stats = [riak_core_metric_proc:value(Name, Presentation) ||
+produce_stats(Level, Group) when is_integer(Level), is_atom(Group) ->
+ Stats = [riak_core_metric_proc:value(Name, Level) ||
{Name, Spec} <- stat_specs(), lists:keyfind(Group, 2, Spec) /= false],
lists:flatten(Stats).
View
12 src/riak_kv_vnode_metric.erl
@@ -42,12 +42,14 @@ update({Cnt, Moment, VNode}, {Meter, VNodes}) ->
update({Cnt, Moment}, {Meter, VNodes}) ->
{riak_core_metric_meter:update({Cnt, Moment}, Meter), VNodes}.
-value(0, Name, {Meter, _VNodes}) ->
+value(Level, Name, {Meter, _VNodes}) when Level < 2->
riak_core_metric_meter:value(0, Name, Meter);
-value(Level, Name, {Meter, VNodes}) when Level > 0 ->
- [riak_core_metric_meter:value(Level, Name, Meter) | display_vnodes(Level, [], Name, VNodes)].
+value(Level, Name, {Meter, VNodes}) when Level > 1 ->
+ [riak_core_metric_meter:value(Level, Name, Meter) | display_vnodes(Level-2, [], Name, VNodes)].
-value(Level, vnodes, Name, {_Meter, VNodes}) ->
+value(Level, [], Name, State) ->
+ value(Level, Name, State);
+value(Level, [vnodes], Name, {_Meter, VNodes}) ->
display_vnodes(Level, [], Name, VNodes);
value(Level, [vnodes, '*'|Field], Name, {_Meter, VNodes}) ->
display_vnodes(Level, Field, Name, VNodes);
@@ -64,7 +66,7 @@ value(Level, [vnodes, VNode|Field], Name, {_Meter, VNodes}) ->
_ ->
[]
end;
-value(Level, Field, Name, {Meter, _VNodes}) ->
+value(Level, [Field], Name, {Meter, _VNodes}) ->
riak_core_metric_meter:value(Level, Field, Name, Meter).
tick({Meter, VNodes}) ->

No commit comments for this range

Something went wrong with that request. Please try again.