You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bookkeeper.apache.org by Sijie Guo <si...@apache.org> on 2016/03/22 20:14:44 UTC

Re: Metrics: resetting counter after reporting

How to handle Counters really depends on the implementation of the stats
providers and how they are collected by the stats collection system. I know
some of the stats libraries latch the counters and reset after they are
collected.

- Sijie


On Tue, Mar 22, 2016 at 10:25 AM, JV Jujjuri <vj...@salesforce.com>
wrote:

> We are in the process of adding more metrics to BK especially in the GC
> area.
> We would like to know how much progress we made between two intervals.
> Say during one cycle of GC, how many deleted ledgers it processed and how
> much space reclaimed.
> This can be constantly increasing statistic or we can reset this counter
> on every GC run.
> If it is constantly increasing, it does overflow our long value eventually
> and become a -ve number.
> How are we dealing with that kind of stats right now in the code? for
> example #of add entries.
>
> Thanks,
> JV
>
> On Mon, Mar 21, 2016 at 4:43 PM, Dustin Castor <dc...@salesforce.com>
> wrote:
>
>> Hello,
>>
>> I had a question regarding resetting the counter after retrieving the
>> metrics for a particular counter. So, for example, say we log the total
>> space reclaimed by a garbage collector iteration. Say we have a counter
>> variable that we defined -- e.g.,
>>
>> final Counter spaceReclaimed;
>>
>>
>> Say we log reclaimed space against this:
>>
>> spaceReclaimed.inc(4800);
>>
>> spaceReclaimed.inc(2800);
>>
>> etc.
>>
>>
>> After the output threshold for our logs is reached and these total sums
>> are reported (as determined by "codahaleStatsOutputFrequencySeconds"
>> setting in bk_server.conf), is there a way to reset this counter back to
>> zero for the next iteration? So rather than having a running total, we'd
>> like to have an instantaneous output for certain values due to fear of
>> overflowing certain variables.
>>
>> Within CodahaleStatsLogger, I see a clear() method for the defined
>> Counter(). I'm thinking about having some sort of "getter" that will reset
>> itself when retrieved by the MetricsRegistry, such as:
>>
>>
>> @Override
>>
>>             public Long get() {
>>
>>                 Long currCount = c.getCount();
>>
>>                 this.clear();
>>
>>             return currCount;
>>
>>             }
>>
>>
>> Is there a setting like this somewhere for the MetricsRegistry? Perhaps
>> I've overlooked it. Otherwise, I can go about adding a new implementation.
>> I just didn't want to deviate too far in the event there was an easier way
>> to accomplish this.
>>
>>
>> Thanks a ton for your help.
>>
>>
>> Best,
>> --
>> Dustin Castor
>> T&P - MTS
>> 2035 NW Cornelius Pass Road
>> Hillsboro, OR 97124
>>
>
>
>
> --
> Venkateswararao Jujjuri (JV)                      2035 NW Cornelius Pass Rd
> Cloud Storage Architect                              Hillsboro, OR 97124
> vjujjuri@salesforce.com                              971 270 6748
>