|
@@ -26,8 +26,8 @@ public class StatisticInterceptor implements HandlerInterceptor {
|
|
|
|
|
|
private MetricRegistry metricRegistry = new MetricRegistry();
|
|
|
|
|
|
- ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS)
|
|
|
- .convertDurationsTo(TimeUnit.MILLISECONDS).build();
|
|
|
+ ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry)
|
|
|
+ .convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
|
|
|
|
|
|
public StatisticInterceptor() {
|
|
|
reporter.start(1, TimeUnit.SECONDS);// 1s报道一次
|
|
@@ -57,6 +57,8 @@ public class StatisticInterceptor implements HandlerInterceptor {
|
|
|
Object handler, Exception ex) throws Exception {
|
|
|
Context ctx = (Context) request
|
|
|
.getAttribute(HttpServletRequestAttribute.$_METRICS_TIMER_CTX.name());
|
|
|
- ctx.stop();
|
|
|
+ if (null != ctx) {
|
|
|
+ ctx.stop();
|
|
|
+ }
|
|
|
}
|
|
|
}
|