Application Metrics
Dropwizard codahale Metrics
MetricRegistry metricRegistry = new MetricRegistry();
ConsoleReporter reporter =
ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.start(1, TimeUnit.SECONDS);
Counter c = metricRegistry.counter("foo"); //counter
c.inc();
Histogram h = metricRegistry.histogram("foo"); //distribution
h.update(200);
Meter m = metricRegistry.meter("foo"); //throughput
m.mark();
m.mark(200);
Timer t = metricRegistry.timer("foo"); //times an event
Timer.Context ctx = t.time();
ctx.stop();
Typical ConsoleReporter output:
2/12/15 8:34:21 PM =============================================================
-- Counters --------------------------------------------------------------------
hlr.assetsOnDupeShards-Advisory
count = 1
hlr.lastSyncScan
count = 2
-- Histograms ------------------------------------------------------------------
hlr.shardAssetCount-shard1
count = 1
min = 10
max = 10
mean = 10.00
stddev = 0.00
median = 10.00
75% <= 10.00
95% <= 10.00
98% <= 10.00
99% <= 10.00
99.9% <= 10.00
hlr.shardAssetCount-shard2
count = 1
min = 10
max = 10
mean = 10.00
stddev = 0.00
median = 10.00
75% <= 10.00
95% <= 10.00
98% <= 10.00
99% <= 10.00
99.9% <= 10.00
-- Timers ----------------------------------------------------------------------
hlr.shardSyncDuration-shard1
count = 1
mean rate = 0.25 calls/second
1-minute rate = 0.00 calls/second
5-minute rate = 0.00 calls/second
15-minute rate = 0.00 calls/second
min = 100.32 milliseconds
max = 100.32 milliseconds
mean = 100.32 milliseconds
stddev = 0.00 milliseconds
median = 100.32 milliseconds
75% <= 100.32 milliseconds
95% <= 100.32 milliseconds
98% <= 100.32 milliseconds
99% <= 100.32 milliseconds
99.9% <= 100.32 milliseconds
hlr.shardSyncDuration-shard2
count = 1
mean rate = 0.25 calls/second
1-minute rate = 0.00 calls/second
5-minute rate = 0.00 calls/second
15-minute rate = 0.00 calls/second
min = 100.67 milliseconds
max = 100.67 milliseconds
mean = 100.67 milliseconds
stddev = 0.00 milliseconds
median = 100.67 milliseconds
75% <= 100.67 milliseconds
95% <= 100.67 milliseconds
98% <= 100.67 milliseconds
99% <= 100.67 milliseconds
99.9% <= 100.67 milliseconds
MetricRegistry metricRegistry = new MetricRegistry();
ConsoleReporter reporter =
ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS).build();
reporter.start(1, TimeUnit.SECONDS);
Counter c = metricRegistry.counter("foo"); //counter
c.inc();
Histogram h = metricRegistry.histogram("foo"); //distribution
h.update(200);
Meter m = metricRegistry.meter("foo"); //throughput
m.mark();
m.mark(200);
Timer t = metricRegistry.timer("foo"); //times an event
Timer.Context ctx = t.time();
ctx.stop();
Typical ConsoleReporter output:
2/12/15 8:34:21 PM =============================================================
-- Counters --------------------------------------------------------------------
hlr.assetsOnDupeShards-Advisory
count = 1
hlr.lastSyncScan
count = 2
-- Histograms ------------------------------------------------------------------
hlr.shardAssetCount-shard1
count = 1
min = 10
max = 10
mean = 10.00
stddev = 0.00
median = 10.00
75% <= 10.00
95% <= 10.00
98% <= 10.00
99% <= 10.00
99.9% <= 10.00
hlr.shardAssetCount-shard2
count = 1
min = 10
max = 10
mean = 10.00
stddev = 0.00
median = 10.00
75% <= 10.00
95% <= 10.00
98% <= 10.00
99% <= 10.00
99.9% <= 10.00
-- Timers ----------------------------------------------------------------------
hlr.shardSyncDuration-shard1
count = 1
mean rate = 0.25 calls/second
1-minute rate = 0.00 calls/second
5-minute rate = 0.00 calls/second
15-minute rate = 0.00 calls/second
min = 100.32 milliseconds
max = 100.32 milliseconds
mean = 100.32 milliseconds
stddev = 0.00 milliseconds
median = 100.32 milliseconds
75% <= 100.32 milliseconds
95% <= 100.32 milliseconds
98% <= 100.32 milliseconds
99% <= 100.32 milliseconds
99.9% <= 100.32 milliseconds
hlr.shardSyncDuration-shard2
count = 1
mean rate = 0.25 calls/second
1-minute rate = 0.00 calls/second
5-minute rate = 0.00 calls/second
15-minute rate = 0.00 calls/second
min = 100.67 milliseconds
max = 100.67 milliseconds
mean = 100.67 milliseconds
stddev = 0.00 milliseconds
median = 100.67 milliseconds
75% <= 100.67 milliseconds
95% <= 100.67 milliseconds
98% <= 100.67 milliseconds
99% <= 100.67 milliseconds
99.9% <= 100.67 milliseconds
Comments