Dropwizard metrics - how to reset counters after reporting interval

I use codahale metrics (now dropwizard metrics) to track several events happening on my system. I use counters metrics to track the amount of time that an event has occurred.

I checked the values ​​printed by the reporter for my counters and it looks like the value continues to increase (and never decreases). This seems logical, because I always use the metrics.inc () function whenever my "event" occurs.

What I really want is to get count of my 'event' happening between two reporting times , for this I need to reset my counter every time I report my indicators, but I could not find any option in the counter metrics to do this. Is there a way or common practice that codahale users follow to create such metrics?

Current behavior (transmission time 10 seconds):

 00:00:00 0 00:00:10 2 // event happened twice 00:00:20 2 // event did not occur 00:00:30 5 // event occured three times` 

Expected Performance:

 00:00:00 0 00:00:10 2 00:00:20 0 00:00:30 3 
+5
source share
2 answers

I believe that counter not the right indicator for your case. Think using a meter that will give you speed over a time interval:

 while(...) { int stuffProcesssed = doStuff(); meter.mark(stuffProcesssed); } 
+1
source

To summarize or calculate the score (total) for any interval:

 hitcount(perSecond(your.count), '1day') 

Afaik, he does all the black magic inside. Including, but not limited to, summarize(scaleToSeconds(nonNegativeDerivative(your.count),1), '1day') and there should also be a scaling in accordance with the carbon retention periods (one or more) that fall into the selected aggregation period.

+1
source

All Articles