Timer is not generating any metrics

36 views
Skip to first unread message

Sreejith S

unread,
Apr 14, 2017, 3:33:54 AM4/14/17
to metrics-user
Hi All, 

I am new to metrics. When i tried with Timer , the report always like below

get-requests
             count = 0
         mean rate = 0.00 calls/second
     1-minute rate = 0.00 calls/second
     5-minute rate = 0.00 calls/second
    15-minute rate = 0.00 calls/second
               min = 0.00 milliseconds
               max = 0.00 milliseconds
              mean = 0.00 milliseconds
            stddev = 0.00 milliseconds
            median = 0.00 milliseconds
              75% <= 0.00 milliseconds
              95% <= 0.00 milliseconds
              98% <= 0.00 milliseconds
              99% <= 0.00 milliseconds
            99.9% <= 0.00 milliseconds

And i am using a sample code like this

final Timer timer = metricRegistry.timer("get-requests");
final Timer.Context context = timer.time();
try {
for(int i=0;i<100;i++) {
counter.inc();
me.mark();
Thread.sleep(1000);
}
} finally {
   context.stop();
}

Is this the right way to do ?

Regards,
Sreejith

Ryan Rupp

unread,
Apr 14, 2017, 7:56:19 PM4/14/17
to metrics-user
Are you waiting the 100 seconds for the loop to complete? Looks okay assuming you're waiting for that sleep loop to complete (which would take 100 seconds). Is the meter and counter you're incrementing in the loop working correctly for you?

Sreejith S

unread,
Apr 16, 2017, 3:34:28 AM4/16/17
to metrics-user
Yes Ryan I am able to see Counter and Meter metrics like below

-- Counters --------------------------------------------------------------------
counter
             count = 78

-- Meters ----------------------------------------------------------------------
requests
             count = 78
         mean rate = 1.00 events/second
     1-minute rate = 1.00 events/second
     5-minute rate = 1.00 events/second
    15-minute rate = 1.00 events/second

But , timer count is always 0.

Regards,
Sreejith

Sreejith S

unread,
Apr 20, 2017, 4:44:29 AM4/20/17
to metrics-user
Any pointers on this ?
Reply all
Reply to author
Forward
0 new messages