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.Filter
Filter
implementation 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 class
AbstractInstrumentedFilter.StatusExposingServletResponse
-
Field Summary
Fields Modifier and Type Field Description private Counter
activeRequests
private java.util.Map<java.lang.Integer,java.lang.String>
meterNamesByStatusCode
private java.util.concurrent.ConcurrentMap<java.lang.Integer,Meter>
metersByStatusCode
private Meter
otherMeter
private java.lang.String
otherMetricName
private java.lang.String
registryAttribute
private Timer
requestTimer
-
Constructor Summary
Constructors Modifier Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
void
doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
private MetricRegistry
getMetricsFactory(javax.servlet.FilterConfig filterConfig)
void
init(javax.servlet.FilterConfig filterConfig)
private void
markMeterForStatusCode(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:
init
in interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
-
getMetricsFactory
private MetricRegistry getMetricsFactory(javax.servlet.FilterConfig filterConfig)
-
destroy
public void destroy()
- Specified by:
destroy
in 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:
doFilter
in interfacejavax.servlet.Filter
- Throws:
java.io.IOException
javax.servlet.ServletException
-
markMeterForStatusCode
private void markMeterForStatusCode(int status)
-
-