public class HttpStopwatchSource extends AbstractStopwatchSource<javax.servlet.http.HttpServletRequest>
SimonServletFilter
as default stopwatch source.
Can be overridden to customize monitored HTTP Requests and their
related Simon name.
To select which HTTP Request should be monitored method isMonitored(javax.servlet.http.HttpServletRequest)
can be overridden. Default implementation monitors everything except for
typical resource-like requests (images, JS/CSS, ...).Modifier and Type | Class and Description |
---|---|
static class |
HttpStopwatchSource.IncludeHttpMethodName
Enum that represents modes of preserving HTTP methods names in Simons' names
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SIMON_PREFIX
Default prefix for web filter Simons if no "prefix" init parameter is used.
|
Constructor and Description |
---|
HttpStopwatchSource(Manager manager) |
Modifier and Type | Method and Description |
---|---|
HttpStopwatchSource.IncludeHttpMethodName |
getIncludeHttpMethodName()
Returns current mode of preserving HTTP method names in simons' names
|
Stopwatch |
getMonitor(javax.servlet.http.HttpServletRequest request)
Get a stopwatch for given HTTP request.
|
protected String |
getMonitorName(javax.servlet.http.HttpServletRequest request)
Returns Simon name for the specified HTTP request with the specified prefix.
|
String |
getPrefix() |
String |
getReplaceUnallowed() |
boolean |
isMonitored(javax.servlet.http.HttpServletRequest httpServletRequest)
Indicates whether the HTTP Request should be monitored - method is intended for override.
|
static StopwatchSource<javax.servlet.http.HttpServletRequest> |
newCacheStopwatchSource(StopwatchSource<javax.servlet.http.HttpServletRequest> stopwatchSource)
Wraps given stop watch source in a cache.
|
protected String |
removeJSessionIdFromUri(String uri)
Removes JSESSIONID parameter from URI.
|
protected String |
removeTrailingStuff(String uri)
Removes any trailing slashes followed by other characters if none of them is alphabetic.
|
protected String |
requestToStringForMonitorName(javax.servlet.http.HttpServletRequest request)
Performs the first step in getting the monitor name from the specified HTTP request - here any custom ignore logic should happen.
|
void |
setIncludeHttpMethodName(HttpStopwatchSource.IncludeHttpMethodName includeHttpMethodName)
Set current mode of preserving HTTP method names in simons' names
|
void |
setPrefix(String prefix) |
void |
setReplaceUnallowed(String replaceUnallowed) |
getManager, start
public static final String DEFAULT_SIMON_PREFIX
public HttpStopwatchSource(Manager manager)
public String getReplaceUnallowed()
public void setReplaceUnallowed(String replaceUnallowed)
public HttpStopwatchSource.IncludeHttpMethodName getIncludeHttpMethodName()
public void setIncludeHttpMethodName(HttpStopwatchSource.IncludeHttpMethodName includeHttpMethodName)
includeHttpMethodName
- current mode of preserving HTTP method namesprotected String getMonitorName(javax.servlet.http.HttpServletRequest request)
requestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
, can be overridden),setReplaceUnallowed(String)
,Manager.HIERARCHY_DELIMITER
)getMonitorName
in class AbstractStopwatchSource<javax.servlet.http.HttpServletRequest>
request
- HTTP requestrequestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
protected String requestToStringForMonitorName(javax.servlet.http.HttpServletRequest request)
HttpServletRequest.getRequestURI()
) with JSessionID
removed (see removeJSessionIdFromUri(String)
) and any trailing stuff removed (see removeTrailingStuff(String)
).
This method can be overridden for two typical reasons:
request
- HTTP requestgetMonitorName(javax.servlet.http.HttpServletRequest)
,
removeJSessionIdFromUri(String)
protected String removeJSessionIdFromUri(String uri)
requestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
and extracted
so it can be used by any overriding implementation of the same method. Method can be overridden if the default behavior is not
sufficient.uri
- preprocessed URI that may contain JSessionIDrequestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
protected String removeTrailingStuff(String uri)
requestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
and extracted
so it can be used by any overriding implementation of the same method. Method can be overridden if the default behavior is not
sufficient.uri
- preprocessed URI that may contain JSessionIDrequestToStringForMonitorName(javax.servlet.http.HttpServletRequest)
public boolean isMonitored(javax.servlet.http.HttpServletRequest httpServletRequest)
isMonitored
in interface MonitorSource<javax.servlet.http.HttpServletRequest,Stopwatch>
isMonitored
in class AbstractStopwatchSource<javax.servlet.http.HttpServletRequest>
httpServletRequest
- HTTP Requestpublic Stopwatch getMonitor(javax.servlet.http.HttpServletRequest request)
getMonitor
in interface MonitorSource<javax.servlet.http.HttpServletRequest,Stopwatch>
getMonitor
in class AbstractStopwatchSource<javax.servlet.http.HttpServletRequest>
request
- Method HTTP requestpublic static StopwatchSource<javax.servlet.http.HttpServletRequest> newCacheStopwatchSource(StopwatchSource<javax.servlet.http.HttpServletRequest> stopwatchSource)
stopwatchSource
- Stopwatch sourceCopyright © 2019. All rights reserved.