Skip to content

Commit

Permalink
Add a combined total+meter (tmeter)
Browse files Browse the repository at this point in the history
  • Loading branch information
russelldb committed Apr 11, 2012
1 parent e95a295 commit a6fc657
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
7 changes: 4 additions & 3 deletions ebin/riak_core.app
Expand Up @@ -38,12 +38,13 @@
riak_core_handoff_sender_sup,
riak_core_handoff_sup,
riak_core_metric,
riak_core_metric_sup,
riak_core_metric_proc,
riak_core_metric_counter,
riak_core_metric_duration,
riak_core_metric_histogram,
riak_core_metric_meter,
riak_core_metric_duration,
riak_core_metric_proc,
riak_core_metric_sup,
riak_core_metric_tmeter,
riak_core_nodeid,
riak_core_node_watcher,
riak_core_node_watcher_events,
Expand Down
43 changes: 43 additions & 0 deletions src/riak_core_metric_tmeter.erl
@@ -0,0 +1,43 @@
%%
%% Copyright (c) 2007-2012 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------

%% @doc A meter and a total counter
-module(riak_core_metric_tmeter).

-behaviour(riak_core_metric).

%% Behaviour API
-export([new/0, value/2, value/3, update/2, tick/1]).

new() ->
{0, riak_core_metric_meter:new()}.

update({Cnt, Moment}, {Counter, Meter}) ->
{Counter+Cnt, riak_core_metric_meter:update({Cnt, Moment}, Meter)}.

value(Name, Value) ->
CounterName = riak_core_metric:join_as_atom([Name, '_', total]),
value({CounterName, Name}, Name, Value).

value({CounterName, MeterName}, _Name, {Counter, Meter}) ->
[{CounterName, Counter},
riak_core_metric_meter:value(MeterName, Meter)].

tick({_Counter, Meter}) ->
riak_core_metric_meter:tick(Meter).
6 changes: 2 additions & 4 deletions src/riak_core_stat.erl
Expand Up @@ -33,11 +33,10 @@
-spec stat_specs() -> riak_core_metric:stat_specs().
stat_specs() ->
[{ignored_gossip_total, [{type, counter}, {group, gossip}]},
{rings_reconciled_total, [{type, counter}, {group, gossip}]},
{rejected_handoffs, [{type, counter}, {group, gossip}]},
{handoff_timeouts, [{type, counter}, {group, gossip}]},
{gossip_received, [{type, meter}, {group, gossip}]},
{rings_reconciled, [{type, meter}, {group, gossip}]},
{rings_reconciled, [{type, tmeter}, {group, gossip}]},
{converge_delay, [{type, duration}, {group, gossip},
{presentation,
[{legacy, [min, max, mean, last]}]}]},
Expand Down Expand Up @@ -73,8 +72,7 @@ update(ignored_gossip) ->
update(gossip_received) ->
riak_core_metric_proc:update(gossip_received, {1, slide:moment()});
update(rings_reconciled) ->
riak_core_metric_proc:update(rings_reconciled, {1, slide:moment()}),
riak_core_metric_proc:update(rings_reconciled_total, 1);
riak_core_metric_proc:update(rings_reconciled, {1, slide:moment()});
update(_) ->
ok.

Expand Down

0 comments on commit a6fc657

Please sign in to comment.