Class MetricsInterceptor
java.lang.Object
org.springframework.web.servlet.handler.HandlerInterceptorAdapter
com.netflix.spinnaker.kork.web.interceptors.MetricsInterceptor
- All Implemented Interfaces:
org.springframework.web.servlet.AsyncHandlerInterceptor,org.springframework.web.servlet.HandlerInterceptor
public class MetricsInterceptor
extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
An interceptor that logs Controller metrics to an underlying
Registry.
A `timer` will be created for each request with the following tags:
- controller name - controller method - status (2xx, 4xx, 5xx, etc.) - statusCode (200, 404, 500, etc.) - success (true/false depending on whether the request resulted in an exception) - cause (if success == false, the name of the raised exception)
-
Constructor Summary
ConstructorsConstructorDescriptionMetricsInterceptor(com.netflix.spectator.api.Registry registry, String metricName, Collection<String> pathVariablesToTag, Collection<String> controllersToExclude) Deprecated.Instead use the other constructor.MetricsInterceptor(com.netflix.spectator.api.Registry registry, String metricName, Collection<String> pathVariablesToTag, Collection<String> queryParamsToTag, Collection<String> controllersToExclude) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) protected LongbooleanpreHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.AsyncHandlerInterceptor
afterConcurrentHandlingStartedMethods inherited from interface org.springframework.web.servlet.HandlerInterceptor
postHandle
-
Constructor Details
-
MetricsInterceptor
@Deprecated public MetricsInterceptor(com.netflix.spectator.api.Registry registry, String metricName, Collection<String> pathVariablesToTag, Collection<String> controllersToExclude) Deprecated.Instead use the other constructor. -
MetricsInterceptor
public MetricsInterceptor(com.netflix.spectator.api.Registry registry, String metricName, Collection<String> pathVariablesToTag, Collection<String> queryParamsToTag, Collection<String> controllersToExclude) - Parameters:
registry- Underlying metrics registrymetricName- Metric namepathVariablesToTag- Variables from the request uri that should be added as metric tagsqueryParamsToTag- Request parameters that should be added as metric tagscontrollersToExclude- Controller names that should be excluded from metrics
-
-
Method Details
-
preHandle
public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception - Throws:
Exception
-
afterCompletion
public void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) throws Exception - Throws:
Exception
-
getNanoTime
-