com.atlassian.jira.web.monitor
Class ActiveRequestsFilter

java.lang.Object
  extended by com.atlassian.jira.web.monitor.ActiveRequestsFilter
All Implemented Interfaces:
javax.servlet.Filter

public class ActiveRequestsFilter
extends Object
implements javax.servlet.Filter

This filter identifies requests that have taken a long time to process, and logs information about the request. This filter is configurable via servlet filter <init-param> properties, and also at runtime via JMX.

Example filter configuration:

 <filter>
     <filter-name>active-requests-filter</filter-name>
     <filter-class>com.atlassian.jira.web.monitor.ActiveRequestsFilter</filter-class>
 

<!-- register in JMX --> <init-param> <param-name>jmx.name</param-name> <param-value>com.atlassian.jira:name=Requests</param-value> </init-param>

<!-- log a INFO entry if a request takes more than this (default: 5s, 0 to disable) --> <init-param> <param-name>request.log.threshold</param-name> <param-value>5000</param-value> </init-param>

<!-- create a thread dump if a request takes more than this (default: 30s, 0 to disable) --> <init-param> <param-name>request.dumpthreads.threshold</param-name> <param-value>30000</param-value> </init-param>

<!-- save the thread dump in the logs directory --> <init-param> <param-name>request.dumpthreads.dir</param-name> <param-value>${catalina.base}/logs</param-value> </init-param> </filter>

This class is thread-safe.

Since:
v4.3

Field Summary
static String JMX_NAME_PARAM
          The name of the init-param used to select the JMX name.
 
Constructor Summary
ActiveRequestsFilter()
          Creates a new ActiveRequestsFilter.
 
Method Summary
 void destroy()
          Destroys this filter, cancelling the associated timer instance.
 void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)
          Adds a request to the #requestsInProgress map when it begins, and removes it once it has finished.
 void init(javax.servlet.FilterConfig filterConfig)
          Initialises this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JMX_NAME_PARAM

public static final String JMX_NAME_PARAM
The name of the init-param used to select the JMX name.

See Also:
Constant Field Values
Constructor Detail

ActiveRequestsFilter

public ActiveRequestsFilter()
Creates a new ActiveRequestsFilter.

Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
Initialises this filter.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - a FilterConfig

doFilter

public void doFilter(javax.servlet.ServletRequest servletRequest,
                     javax.servlet.ServletResponse servletResponse,
                     javax.servlet.FilterChain filterChain)
              throws IOException,
                     javax.servlet.ServletException
Adds a request to the #requestsInProgress map when it begins, and removes it once it has finished.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
servletRequest - a ServletRequest
servletResponse - a ServletResponse
filterChain - a FilterChain
Throws:
IOException - if there is a problem somewhere down the interceptor chain
javax.servlet.ServletException - if there is a problem somewhere down the interceptor chain

destroy

public void destroy()
Destroys this filter, cancelling the associated timer instance.

Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2002-2012 Atlassian. All Rights Reserved.