Java Code Examples for io.prometheus.client.Histogram#Timer
The following examples show how to use
io.prometheus.client.Histogram#Timer .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CallMeterChildImpl.java From resilience4j with Apache License 2.0 | 6 votes |
@Override public Timer startTimer() { final Histogram.Timer timer = histogram.startTimer(); totalCounter.inc(); return new Timer() { @Override public void onError() { errorCounter.inc(); } @Override public void onSuccess() { timer.observeDuration(); } }; }
Example 2
Source File: CallMeterImpl.java From resilience4j with Apache License 2.0 | 6 votes |
@Override public Timer startTimer() { final Histogram.Timer timer = collectors.histogram.startTimer(); collectors.totalCounter.inc(); return new Timer() { @Override public void onError() { collectors.errorCounter.inc(); } @Override public void onSuccess() { timer.observeDuration(); } }; }
Example 3
Source File: MetricsFilter.java From client_java with Apache License 2.0 | 6 votes |
@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(); } }
Example 4
Source File: MetricsCollectorFilter.java From Architecting-Modern-Java-EE-Applications with MIT License | 5 votes |
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { if (!(req instanceof HttpServletRequest)) { chain.doFilter(req, res); return; } String url = ((HttpServletRequest) req).getRequestURI(); try (Histogram.Timer ignored = requestDuration.labels(url).startTimer()) { chain.doFilter(req, res); } }
Example 5
Source File: PrometheusMetrics.java From vertx-kafka-service with Apache License 2.0 | 5 votes |
public InProgressMessage messageStarted() { MESSAGES.labels(topic, consumerGroup, instanceId).inc(); IN_PROGRESS_MESSAGES.labels(topic, consumerGroup, instanceId).inc(); final Histogram.Timer timer = DURATION_HISTOGRAM.labels(topic, consumerGroup, instanceId).startTimer(); return () -> { timer.observeDuration(); IN_PROGRESS_MESSAGES.labels(topic, consumerGroup, instanceId).dec(); }; }
Example 6
Source File: OMetricsRequestCycleListener.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public void onBeginRequest(RequestCycle cycle) { Histogram.Timer requestTimer = HISTOGRAM_REQUESTS .labels(Boolean.toString(((WebRequest)cycle.getRequest()).isAjax())) .startTimer(); cycle.setMetaData(REQUESTS_HISTOGRAM_KEY, requestTimer); }
Example 7
Source File: RequestLatencyHistogramMetricsTracker.java From soul with Apache License 2.0 | 4 votes |
@Override public HistogramMetricsTrackerDelegate startTimer(final String... labelValues) { Histogram.Timer timer = REQUEST_LATENCY.startTimer(); return new PrometheusHistogramMetricsTrackerDelegate(timer); }
Example 8
Source File: RequestLatencyHistogramMetricsTracker.java From shardingsphere with Apache License 2.0 | 4 votes |
@Override public HistogramMetricsTrackerDelegate startTimer(final String... labelValues) { Histogram.Timer timer = REQUEST_LATENCY.startTimer(); return new PrometheusHistogramMetricsTrackerDelegate(timer); }
Example 9
Source File: OMetricsRequestCycleListener.java From Orienteer with Apache License 2.0 | 4 votes |
@Override public void onEndRequest(RequestCycle cycle) { Histogram.Timer requestTimer = cycle.getMetaData(REQUESTS_HISTOGRAM_KEY); requestTimer.observeDuration(); }