Package com.codahale.metrics.servlet
Class AbstractInstrumentedFilter
- java.lang.Object
-
- com.codahale.metrics.servlet.AbstractInstrumentedFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
- Direct Known Subclasses:
InstrumentedFilter
public abstract class AbstractInstrumentedFilter extends java.lang.Object implements javax.servlet.FilterFilterimplementation which captures request information and a breakdown of the response codes being returned.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractInstrumentedFilter.StatusExposingServletResponse
-
Field Summary
Fields Modifier and Type Field Description private CounteractiveRequestsprivate java.util.Map<java.lang.Integer,java.lang.String>meterNamesByStatusCodeprivate java.util.concurrent.ConcurrentMap<java.lang.Integer,Meter>metersByStatusCodeprivate MeterotherMeterprivate java.lang.StringotherMetricNameprivate java.lang.StringregistryAttributeprivate TimerrequestTimer
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractInstrumentedFilter(java.lang.String registryAttribute, java.util.Map<java.lang.Integer,java.lang.String> meterNamesByStatusCode, java.lang.String otherMetricName)Creates a new instance of the filter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)private MetricRegistrygetMetricsFactory(javax.servlet.FilterConfig filterConfig)voidinit(javax.servlet.FilterConfig filterConfig)private voidmarkMeterForStatusCode(int status)
-
-
-
Field Detail
-
otherMetricName
private final java.lang.String otherMetricName
-
meterNamesByStatusCode
private final java.util.Map<java.lang.Integer,java.lang.String> meterNamesByStatusCode
-
registryAttribute
private final java.lang.String registryAttribute
-
metersByStatusCode
private java.util.concurrent.ConcurrentMap<java.lang.Integer,Meter> metersByStatusCode
-
otherMeter
private Meter otherMeter
-
activeRequests
private Counter activeRequests
-
requestTimer
private Timer requestTimer
-
-
Constructor Detail
-
AbstractInstrumentedFilter
protected AbstractInstrumentedFilter(java.lang.String registryAttribute, java.util.Map<java.lang.Integer,java.lang.String> meterNamesByStatusCode, java.lang.String otherMetricName)Creates a new instance of the filter.- Parameters:
registryAttribute- the attribute used to look up the metrics registry in the servlet contextmeterNamesByStatusCode- A map, keyed by status code, of meter names that we are interested in.otherMetricName- The name used for the catch-all meter.
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
getMetricsFactory
private MetricRegistry getMetricsFactory(javax.servlet.FilterConfig filterConfig)
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.servlet.Filter
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException- Specified by:
doFilterin interfacejavax.servlet.Filter- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
markMeterForStatusCode
private void markMeterForStatusCode(int status)
-
-