/** * stop timer */ public void finished(){ this.timer.stop(); }
@Override public Object call() throws Exception { // TODO perhaps this could be pushed down further into CountProducer Impl? // - this would leave generic submitter class for ( Count c : counts ) { logger.info( "found count {}", c ); } timer.stop(); return true; } } );
@Override public Object call() throws Exception { cassandraCounterStore.save( counts ); timer.stop(); return true; } } );
/** Add a count object to this batcher */ public void add( Count count ) throws CounterProcessingUnavailableException { invocationCounter.inc(); final TimerContext context = addTimer.time(); if ( batchSize == 1 ) { getBatch().addSerial( count ); } else { getBatch().add( count ); } context.stop(); }
@Override public void stop(final Object token, final String tagName, final boolean success) { final TimerContext timerContext = (TimerContext) token; timerContext.stop(); }
timerCtx.stop();
/** * Stops request timer. * * @param requestTimerContext * timer context */ public void stopTimer(TimerContext requestTimerContext) { requestTimerContext.stop(); } }
/** * Stop timer. */ public void stopTimer() { context.stop(); } }
//this creates or returns the metrics, basically every metric is only created once and registered in a registry private final Timer timerCanMakeHold = Metrics.newTimer(MyClass.class, "METRICNAME", TimeUnit.MILLISECONDS, TimeUnit.SECONDS); final TimerContext timerContex = timerCanMakeHold.time(); try{ doSomeWork()//this is what you are timing }finally{ timerContex.stop(); }
@Override public void stop(final Object token, final String tagName, final boolean success) { final TimerContext timerContext = (TimerContext) token; timerContext.stop(); }
@Override public boolean checkAndClear() { context.stop(); return super.checkAndClear(); }
@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { LOG.info("timer {} - connect took: {}ms", tag, String.format("%.2f", (System.nanoTime() - connectStart) / NANO_TO_MS)); connectContext.stop(); super.channelConnected(ctx, e); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { final TimerContext ctx = timer.time(); try { return invocation.proceed(); } finally { ctx.stop(); } } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { final Timer timer = timers.get(invocation.getMethod().getName()); final TimerContext timerCtx = timer != null ? timer.time() : null; try { return invocation.proceed(); } finally { if (timerCtx != null) { timerCtx.stop(); } } }
private static boolean executeAndTimeInsert(PreparedStatement preparedStatement) throws SQLException { TimerContext timerContext = insertTimer.time(); try { return preparedStatement.execute(); } catch (SQLException e) { errorCounter.inc(); throw e; } finally { timerContext.stop(); } }
@Override public void hiveReadRowFailed() { readSuccessRatio.getDenominatorCounter().inc(); readTimerContext.stop(); }
@Override public void dispatch(Object resource, HttpContext httpContext) { final TimerContext context = timer.time(); try { underlying.dispatch(resource, httpContext); } finally { context.stop(); } } }
public static BufferedImage crop(BufferedImage image, Rectangle bounds) throws Exception { TimerContext cropContext = cropTimer.time(); BufferedImage result = AsyncScalr.crop(image, bounds.x, bounds.y, bounds.width, bounds.height).get(); image.flush(); cropContext.stop(); return result; } }
public static BufferedImage rotate(BufferedImage image, Scalr.Rotation rotation) throws Exception { TimerContext rotateContext = rotateTimer.time(); BufferedImage result = AsyncScalr.rotate(image, rotation).get(); image.flush(); rotateContext.stop(); return result; }
@Override public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws HttpException, IOException { final TimerContext timerContext = timer(request).time(); try { return super.execute(target, request, context); } finally { timerContext.stop(); } }