@Override public long getThrownAway() { return thrownAway.getCount(); }
@Override public long getProcessedWithError() { return processedWithError.getCount(); }
@Override public long getProcessed() { return processed.getCount(); }
@Override public long getUnparseable() { return unparseable.getCount(); }
@Override public long getCount() { return meter.getCount(); } }
@Override public long getCount() { return meter.getCount(); }
/** * Update the {@link #recordsWrittenMeter} using the {@link DataWriter#recordsWritten()} method.. */ private synchronized void updateRecordsWrittenMeter() { if (this.recordsWrittenMeter.isPresent()) { this.recordsWrittenMeter.get().mark(recordsWritten() - this.recordsWrittenMeter.get().getCount()); } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { if (responseContext.hasEntity()) { Exception e = (Exception) responseContext.getEntity(); if (exceptionClass.isAssignableFrom(e.getClass()) || (e.getCause() != null && exceptionClass.isAssignableFrom(e.getCause().getClass()))) { meter.mark(); } responseContext.setEntity(null); responseContext.getHeaders().add("X-Exceptions-Thrown", e.toString() + " : " + meter.getCount()); } } }
public static Map<String, Long> dumpMetrics(MetricContext context) { Map<String, Long> output = new HashMap<>(); for (Map.Entry<String, Meter> entry : context.getMeters().entrySet()) { output.put(entry.getKey(), entry.getValue().getCount()); } for (Map.Entry<String, Timer> entry : context.getTimers().entrySet()) { output.put(entry.getKey(), entry.getValue().getCount()); } return output; }
public static Map<String, Object> buildMeterMap(Meter m) { Map<String, Object> metrics = Maps.newHashMap(); if (m == null) { return metrics; } Map<String, Object> rate = Maps.newHashMap(); rate.put("one_minute", m.getOneMinuteRate()); rate.put("five_minute", m.getFiveMinuteRate()); rate.put("fifteen_minute", m.getFifteenMinuteRate()); rate.put("total", m.getCount()); rate.put("mean", m.getMeanRate()); metrics.put("rate_unit", "events/second"); metrics.put("rate", rate); return metrics; }
@Override public synchronized void reset() throws IOException { super.reset(); this.prevCount = this.meter.getBytesProcessedMeter().getCount(); }
private long getMessageParseFailures() { return StreamingKafkaSpecConsumer.this._jobMonitor.getMessageParseFailures() != null? StreamingKafkaSpecConsumer.this._jobMonitor.getMessageParseFailures().getCount():0; } }
@Test public void testCopyMeter() throws Exception { String testString = "This is a string"; Meter meter = new MetricRegistry().meter("my.meter"); ByteArrayInputStream inputStream = new ByteArrayInputStream(testString.getBytes(Charsets.UTF_8)); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); new StreamCopier(inputStream, outputStream).withCopySpeedMeter(meter).copy(); Assert.assertEquals(testString, new String(outputStream.toByteArray(), Charsets.UTF_8)); Assert.assertEquals(meter.getCount(), testString.length()); }
public static Meter meter(long count) { final Meter meter = mock(Meter.class); when(meter.getCount()).thenReturn(count); when(meter.getMeanRate()).thenReturn(2.0); when(meter.getOneMinuteRate()).thenReturn(3.0); when(meter.getFiveMinuteRate()).thenReturn(4.0); when(meter.getFifteenMinuteRate()).thenReturn(5.0); return meter; }
private void printMeter(Meter meter) { this.outputBufferPrintStream.printf(locale, " count = %d%n", meter.getCount()); this.outputBufferPrintStream.printf(locale, " mean rate = %2.2f events/%s%n", convertRate(meter.getMeanRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 1-minute rate = %2.2f events/%s%n", convertRate(meter.getOneMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 5-minute rate = %2.2f events/%s%n", convertRate(meter.getFiveMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 15-minute rate = %2.2f events/%s%n", convertRate(meter.getFifteenMinuteRate()), getRateUnit()); }
@Test public void testLogging() throws Exception { logger.error("test"); final Map<MetricName, Meter> meters = Stagemonitor.getMetric2Registry().getMeters(); assertNotNull(meters.get(name("logging").tag("log_level", "error").build())); assertEquals(1, meters.get(name("logging").tag("log_level", "error").build()).getCount()); } }
@Test public void testRemoved() throws Exception { cacheUsageListener.notifyCacheElementRemoved(); final MetricName name = name("cache_delete").tag("cache_name", "cache").tag("reason", "remove").tier("All").build(); assertNotNull(registry.getMeters().get(name)); assertEquals(1, registry.getMeters().get(name).getCount()); }
@Test public void testCacheHit() throws Exception { cacheUsageListener.notifyCacheHitInMemory(); cacheUsageListener.notifyCacheHitOffHeap(); cacheUsageListener.notifyCacheHitOnDisk(); final MetricName name = name("cache_hits").tag("cache_name", "cache").tier("All").build(); assertNotNull(registry.getMeters().get(name)); assertEquals(3, registry.getMeters().get(name).getCount()); }