Hi,

I have a window function with a window width of 1 min. I want to have an
hourly counter which is reset every hour so it never overflows. There are
multiple ways but none of them is straightforward:

StatsDClient instance = new NonBlockingStatsDClientBuilder()

int count = 0;

void incr() {
  metricClient.count("mycounter", 1, "mytag");

  count++;

}

void reset() {
   metricClient.count("mycounter", -count, "mytag");

   count = 0;

}

As you can see, the code needs to maintain a "count" variable to reset
mycounter.
Also since timer is not available in Window function, extra code is
needed to reset mycounter every hour.
Is there an easier way for implementing hourly counter? Or it is not a
concern that a counter will overflow?

Thanks

Lian

Reply via email to