|
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
|
|
|
import com.codahale.metrics.ConsoleReporter;
|
|
|
+import com.codahale.metrics.Meter;
|
|
|
import com.codahale.metrics.MetricRegistry;
|
|
|
import com.codahale.metrics.Timer;
|
|
|
import com.codahale.metrics.Timer.Context;
|
|
@@ -60,5 +61,18 @@ public class StatisticInterceptor implements HandlerInterceptor {
|
|
|
if (null != ctx) {
|
|
|
ctx.stop();
|
|
|
}
|
|
|
+ Boolean hasException = (Boolean) request
|
|
|
+ .getAttribute(HttpServletRequestAttribute.$_EXCEPTION_HAPPENED.name());
|
|
|
+
|
|
|
+ if (null != hasException && hasException) {
|
|
|
+ ApiInfo apiInfo = (ApiInfo) request
|
|
|
+ .getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
|
|
|
+
|
|
|
+ if (null != apiInfo) {
|
|
|
+ Meter meter = metricRegistry.meter(apiInfo.getMapping());
|
|
|
+ meter.mark();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|