@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (!(servletRequest instanceof HttpServletRequest)) { filterChain.doFilter(servletRequest, servletResponse); return; } HttpServletRequest request = (HttpServletRequest) servletRequest; String path = request.getRequestURI(); Histogram.Timer timer = histogram .labels(getComponents(path), request.getMethod()) .startTimer(); try { filterChain.doFilter(servletRequest, servletResponse); } finally { timer.observeDuration(); } }
/** * Executes callable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run. * * @param timeable Code that is being timed * @return Result returned by callable. */ public <E> E time(Callable<E> timeable) { Timer timer = startTimer(); try { return timeable.call(); } catch (Exception e) { throw new RuntimeException(e); } finally { timer.observeDuration(); } }
/** * Executes runnable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run. * * @param timeable Code that is being timed * @return Measured duration in seconds for timeable to complete. */ public double time(Runnable timeable) { Timer timer = startTimer(); double elapsed; try { timeable.run(); } finally { elapsed = timer.observeDuration(); } return elapsed; }
} finally { if (timer != null) { timer.observeDuration();
cmd.onCommand(event.getAuthor(), guild, event.getChannel(), event.getMessage(), args, event .getMember()); executionTimer.observeDuration(); Metrics.commandsExecuted.labels(cmd.getClass().getSimpleName()).inc();
command.on(context); } finally { requestTimer.observeDuration();
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (!(servletRequest instanceof HttpServletRequest)) { filterChain.doFilter(servletRequest, servletResponse); return; } HttpServletRequest request = (HttpServletRequest) servletRequest; if (!request.isAsyncStarted()) { String context = getContext(request); servletConcurrentRequest.labels(context).inc(); Histogram.Timer timer = servletLatency .labels(context, request.getMethod()) .startTimer(); try { filterChain.doFilter(servletRequest, servletResponse); } finally { timer.observeDuration(); servletConcurrentRequest.labels(context).dec(); servletStatusCodes.labels(context, Integer.toString(getStatus((HttpServletResponse) servletResponse))).inc(); } } else { filterChain.doFilter(servletRequest, servletResponse); } }
/** * Executes callable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run. * * @param timeable Code that is being timed * @return Result returned by callable. */ public <E> E time(Callable<E> timeable) { Timer timer = startTimer(); try { return timeable.call(); } catch (Exception e) { throw new RuntimeException(e); } finally { timer.observeDuration(); } }
/** * Executes runnable code (e.g. a Java 8 Lambda) and observes a duration of how long it took to run. * * @param timeable Code that is being timed * @return Measured duration in seconds for timeable to complete. */ public double time(Runnable timeable) { Timer timer = startTimer(); double elapsed; try { timeable.run(); } finally { elapsed = timer.observeDuration(); } return elapsed; }
/** * Equivalent to calling {@link #observeDuration()}. */ @Override public void close() { observeDuration(); } }
private void invokeIntent(Message message, DatabaseEventHolder databaseEventHolder, AIResponse response, Intent intent) { Metrics.aiRequestsExecuted.labels(intent.getClass().getSimpleName()).inc(); Histogram.Timer timer = Metrics.aiExecutionTime.labels(intent.getClass().getSimpleName()).startTimer(); intent.onIntent(new CommandMessage( null, databaseEventHolder, message ), response); timer.observeDuration(); }
/** * Equivalent to calling {@link #observeDuration()}. */ @Override public void close() { observeDuration(); } }
@Override public void onSuccess() { timer.observeDuration(); } };
@Override public void onSuccess() { timer.observeDuration(); } };