|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectorg.javasimon.javaee.SimonServletFilter
public class SimonServletFilter
Simon Servlet filter measuring HTTP request execution times. Non-HTTP usages are not supported. Filter provides these functions:
INIT_PARAM_SIMON_CONSOLE_PATH is used in web.xmlshouldBeReported(javax.servlet.http.HttpServletRequest, long, java.util.List) - compares actual request nano time with getThreshold(javax.servlet.http.HttpServletRequest)
(which may become unused if this method is overridden)getThreshold(javax.servlet.http.HttpServletRequest) - returns threshold configured in web.xmlRequestReporter can be implemented and specified using init parameter INIT_PARAM_REQUEST_REPORTER_CLASSHttpStopwatchSource can be subclassed and specified using init parameter INIT_PARAM_STOPWATCH_SOURCE_CLASS, specifically
following methods are intended for override:
HttpStopwatchSource.isMonitored(javax.servlet.http.HttpServletRequest) - true except for request with typical resource suffixes
(.gif, .jpg, .css, etc.)HttpStopwatchSource.getMonitorName(javax.servlet.http.HttpServletRequest)
| Field Summary | |
|---|---|
protected String |
consolePath
URL path that displays Simon web console (or null if no console is required). |
static String |
INIT_PARAM_PREFIX
Name of filter init parameter for Simon name prefix. |
static String |
INIT_PARAM_REPORT_THRESHOLD_MS
Name of filter init parameter that sets the value of threshold in milliseconds for maximal request duration beyond which all splits will be dumped to log. |
static String |
INIT_PARAM_REQUEST_REPORTER_CLASS
FQN of the RequestReporter implementation that is used to report requests
that shouldBeReported(javax.servlet.http.HttpServletRequest, long, java.util.List). |
static String |
INIT_PARAM_SIMON_CONSOLE_PATH
Name of filter init parameter that sets relative ULR path that will provide Simon console page. |
static String |
INIT_PARAM_STOPWATCH_SOURCE_CACHE
Enable/disable caching on Stopwatch resolution. |
static String |
INIT_PARAM_STOPWATCH_SOURCE_CLASS
FQN of the Stopwatch source class implementing MonitorSource. |
static String |
INIT_PARAM_STOPWATCH_SOURCE_PROPS
Properties for a StopwatchSource class. |
protected String |
printTreePath
URL path that displays Simon tree - it is console-path without the ending slash. |
protected Long |
reportThresholdNanos
Threshold in ns - any request longer than this will be reported by current requestReporter instance. |
| Constructor Summary | |
|---|---|
SimonServletFilter()
|
|
| Method Summary | |
|---|---|
void |
destroy()
Removes the splitSaverCallback if initialized. |
void |
doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
Wraps the HTTP request with Simon measuring. |
Manager |
getManager()
|
protected long |
getThreshold(javax.servlet.http.HttpServletRequest request)
Returns actual threshold in *nanoseconds* (not ms as configured) which allows to further customize threshold per request - intended for override. |
void |
init(javax.servlet.FilterConfig filterConfig)
Initialization method that processes various init parameters from web.xml and sets manager, if SimonUtils.MANAGER_SERVLET_CTX_ATTRIBUTE servlet context attribute is not null. |
protected boolean |
shouldBeReported(javax.servlet.http.HttpServletRequest request,
long requestNanoTime,
List<Split> splits)
Determines whether the request is over the threshold - with all incoming parameters this method can be very flexible. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String INIT_PARAM_PREFIX
public static final String INIT_PARAM_REPORT_THRESHOLD_MS
getThreshold(javax.servlet.http.HttpServletRequest) method,
but this parameter has to be set to non-null value to enable threshold reporting feature (0 for instance).
public static final String INIT_PARAM_SIMON_CONSOLE_PATH
public static final String INIT_PARAM_STOPWATCH_SOURCE_CLASS
MonitorSource.
One can use DisabledMonitorSource to disabled monitoring.
Defaults to HttpStopwatchSource.
public static final String INIT_PARAM_STOPWATCH_SOURCE_CACHE
HttpServletRequest.getRequestURI(),
this is incompatible with application passing data in their
request URI, this is often the case of RESTful services.
For instance "/car/1023/driver" and "/car/3624/driver"
may point to the same page but with different URLs.
Defaults to false.
public static final String INIT_PARAM_REQUEST_REPORTER_CLASS
RequestReporter implementation that is used to report requests
that shouldBeReported(javax.servlet.http.HttpServletRequest, long, java.util.List).
Default is DefaultRequestReporter.
public static final String INIT_PARAM_STOPWATCH_SOURCE_PROPS
INIT_PARAM_STOPWATCH_SOURCE_CLASS
protected Long reportThresholdNanos
requestReporter instance.
Specified by INIT_PARAM_REPORT_THRESHOLD_MS ("report-threshold-ms") in the web.xml (in ms,
converted to ns during servlet init). This is the default value returned by getThreshold(javax.servlet.http.HttpServletRequest)
but it may be completely ignored if method is overridden so. However if the field is null threshold reporting feature
is disabled.
protected String printTreePath
protected String consolePath
| Constructor Detail |
|---|
public SimonServletFilter()
| Method Detail |
|---|
public final void init(javax.servlet.FilterConfig filterConfig)
SimonUtils.MANAGER_SERVLET_CTX_ATTRIBUTE servlet context attribute is not null.
init in interface javax.servlet.FilterfilterConfig - filter config object
public final void doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterservletRequest - HTTP servlet requestservletResponse - HTTP servlet responsefilterChain - filter chain
IOException - possibly thrown by other filter/servlet in the chain
javax.servlet.ServletException - possibly thrown by other filter/servlet in the chain
protected boolean shouldBeReported(javax.servlet.http.HttpServletRequest request,
long requestNanoTime,
List<Split> splits)
getThreshold(javax.servlet.http.HttpServletRequest) (which by default returns value configured
in web.xml)
request - HTTP servlet requestrequestNanoTime - actual HTTP request nano timesplits - all splits started for the request
true, if request should be reported as over thresholdprotected long getThreshold(javax.servlet.http.HttpServletRequest request)
reportThresholdNanos (already converted to ns).
request - HTTP Request
public Manager getManager()
public void destroy()
destroy in interface javax.servlet.Filter
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||