/** * Record a duration to the dynamic timer indicated by the provided config. * The units in which the timer is reported and the duration unit are the same. * * @deprecated Use {@link DynamicTimer#record(MonitorConfig, java.util.concurrent.TimeUnit, * long, java.util.concurrent.TimeUnit)} instead. * The new method allows you to be specific about the units used for reporting the timer and * the units in which the duration is measured. */ public static void record(MonitorConfig config, long duration, TimeUnit unit) { INSTANCE.get(config, unit).record(duration, unit); }
/** * {@inheritDoc} */ @Override public void record(long duration, TimeUnit timeUnit) { getMonitorForCurrentContext().record(duration, timeUnit); }
/** * Record result to the dynamic timer indicated by the provided config * with a TimeUnit of milliseconds. */ public static void record(MonitorConfig config, long duration) { INSTANCE.get(config, TimeUnit.MILLISECONDS).record(duration, TimeUnit.MILLISECONDS); }
/** * Record a duration to the dynamic timer indicated by the provided config/reportUnit. * * @param config Config to identify a particular timer instance to update. * @param reportUnit The unit to use when reporting values to observers. For example if sent to * a typical time series graphing system this would be the unit * for the y-axis. * It is generally recommended to use base units for reporting, so * {@link TimeUnit#SECONDS} is the preferred value. * @param duration Measured duration to record. * @param durationUnit Unit for the measured duration. This should typically be the unit used for * timing source. For example if using {@link System#nanoTime()} * the unit would be nanoseconds. */ public static void record(MonitorConfig config, TimeUnit reportUnit, long duration, TimeUnit durationUnit) { INSTANCE.get(config, reportUnit).record(duration, durationUnit); }
/** * {@inheritDoc} */ @Override @Deprecated public void record(long duration) { Timer monitor = getMonitorForCurrentContext(); monitor.record(duration, monitor.getTimeUnit()); }
/** * {@inheritDoc} */ @Override public void stop() { super.stop(); timer.record(getDuration(), TimeUnit.NANOSECONDS); } }
@Test public void testGetValue() throws Exception { Stopwatch s = DynamicTimer.start("test1", tagList); Timer c = getByName("test1"); s.stop(); // we don't call s.stop(), so we only have one recorded value assert c != null; assertEquals(c.getValue().longValue(), s.getDuration(TimeUnit.MILLISECONDS)); c.record(13, TimeUnit.MILLISECONDS); long expected = (13 + s.getDuration(TimeUnit.MILLISECONDS)) / 2; assertEquals(c.getValue().longValue(), expected); }
@Override protected void onFlushSuccess(long duration, TimeUnit timeUnit) { decrementLongGauge(pendingFlushes); flushTimes.record(duration, timeUnit); }
/** * Record result to the dynamic timer indicated by the provided config * with a TimeUnit of milliseconds. */ public static void record(MonitorConfig config, long duration) { INSTANCE.get(config, TimeUnit.MILLISECONDS).record(duration, TimeUnit.MILLISECONDS); }
@Override protected void onFlushSuccess(long duration, TimeUnit timeUnit) { decrementLongGauge(pendingFlushes); flushTimes.record(duration, timeUnit); }
@Override protected void onFlushSuccess(long duration, TimeUnit timeUnit) { decrementLongGauge(pendingFlushes); flushTimes.record(duration, timeUnit); }
@Override protected void onWriteSuccess(long duration, TimeUnit timeUnit, long bytesWritten) { decrementLongGauge(pendingWrites); this.bytesWritten.increment(bytesWritten); writeTimes.record(duration, timeUnit); }
@Override protected void onWriteSuccess(long duration, TimeUnit timeUnit, long bytesWritten) { decrementLongGauge(pendingWrites); this.bytesWritten.increment(bytesWritten); writeTimes.record(duration, timeUnit); }
@Override protected void onWriteSuccess(long duration, TimeUnit timeUnit, long bytesWritten) { decrementLongGauge(pendingWrites); this.bytesWritten.increment(bytesWritten); writeTimes.record(duration, timeUnit); }
/** * {@inheritDoc} */ @Override public void stop() { super.stop(); timer.record(getDuration(), TimeUnit.NANOSECONDS); } }
@Override protected void onWriteSuccess(long duration, TimeUnit timeUnit, long bytesWritten) { decrementLongGauge(pendingWrites); this.bytesWritten.increment(bytesWritten); writeTimes.record(duration, timeUnit); }
@Override protected void onHandshakeSuccess(long duration, TimeUnit timeUnit) { decrementLongGauge(inflightHandshakes); incrementLongGauge(processedHandshakes); handshakeProcessingTimes.record(duration, timeUnit); }
@Override protected void onConnectSuccess(long duration, TimeUnit timeUnit) { decrementLongGauge(pendingConnects); incrementLongGauge(liveConnections); connectionCount.increment(); connectionTimes.record(duration, timeUnit); }
@Override protected void onHandshakeFailure(long duration, TimeUnit timeUnit, Throwable throwable) { decrementLongGauge(inflightHandshakes); incrementLongGauge(processedHandshakes); incrementLongGauge(failedHandshakes); handshakeProcessingTimes.record(duration, timeUnit); }
@Override protected void onHandshakeFailure(long duration, TimeUnit timeUnit, Throwable throwable) { decrementLongGauge(inflightHandshakes); incrementLongGauge(processedHandshakes); incrementLongGauge(failedHandshakes); handshakeProcessingTimes.record(duration, timeUnit); }