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 Object implements javax.servlet.Filter
Filter implementation which captures request information and a breakdown of the response codes being returned.
  • Field Details

    • otherMetricName

      private final String otherMetricName
    • meterNamesByStatusCode

      private final Map<Integer,String> meterNamesByStatusCode
    • registryAttribute

      private final String registryAttribute
    • metersByStatusCode

      private ConcurrentMap<Integer,Meter> metersByStatusCode
    • otherMeter

      private Meter otherMeter
    • activeRequests

      private Counter activeRequests
    • requestTimer

      private Timer requestTimer
  • Constructor Details

    • AbstractInstrumentedFilter

      protected AbstractInstrumentedFilter(String registryAttribute, Map<Integer,String> meterNamesByStatusCode, String otherMetricName)
      Creates a new instance of the filter.
      Parameters:
      registryAttribute - the attribute used to look up the metrics registry in the servlet context
      meterNamesByStatusCode - A map, keyed by status code, of meter names that we are interested in.
      otherMetricName - The name used for the catch-all meter.
  • Method Details

    • init

      public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
      Specified by:
      init in interface javax.servlet.Filter
      Throws:
      javax.servlet.ServletException
    • getMetricsFactory

      private MetricRegistry getMetricsFactory(javax.servlet.FilterConfig filterConfig)
    • destroy

      public void destroy()
      Specified by:
      destroy in interface javax.servlet.Filter
    • doFilter

      public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
      Specified by:
      doFilter in interface javax.servlet.Filter
      Throws:
      IOException
      javax.servlet.ServletException
    • markMeterForStatusCode

      private void markMeterForStatusCode(int status)