I was experimenting with micrometer using below code. How do i configure rate aggregation and get rate-aggregated data from a given counter within the application. By rate aggregated i mean data for previous publishing interval ?
final MeterRegistry myRegistry = new SimpleMeterRegistry();
final Random random = new Random();
for (iteration = 0; iteration < 1000; iteration++)
{
final int randomNum = random.nextInt(10);
final Counter myCounter = myRegistry.counter("myTestCounter", "random", Integer.toString(randomNum));
myCounter.increment();
Thread.sleep(100);
}
System.out.println("measure = [" + myRegistry.counter("myTestCounter", "random", "0").measure());
System.out.println("count = [" + myRegistry.counter("myTestCounter", "random", "0").count());
Note: I dont want to publish metrics to any monitoring system. I would like to track number of requests given tags per interval (e.g., successful/failure requests for a given interval) in application itself and use it for resilience purpose.