Request Timing1.0
Provides warnings and diagnostic info for slow or hung requests.
Enabling this feature
To enable the Request Timing 1.0 feature, add the following element declaration into your server.xml
file, inside the featureManager
element:
<feature>requestTiming-1.0</feature>
Examples
Configure slow and hung request thresholds
By default, the requestTiming
element detects requests as slow if the requests require more than 10 seconds to complete, or as hung if the requests do not complete in 10 minutes. The following example sets the slow request threshold to 5 seconds and sets the hung request threshold to 5 minutes for all requests:
<requestTiming slowRequestThreshold="5s" hungRequestThreshold="5m">
</requestTiming>
Configure JDBC request thresholds
The following example sets the slow and hung JDBC request thresholds within the requestTiming
element for any JDBC data source that is specified with the dataSourceName
attribute. The jdbcTiming
element detects that the JDBC request is slow if the request requires more than 500 ms to complete, or hung if the request does not complete in 5 minutes:
<requestTiming slowRequestThreshold="5s" hungRequestThreshold="5m">
<jdbcTiming dataSourceName="testDBSource" slowRequestThreshold="500ms" hungRequestThreshold="5m"/>
</requestTiming>
The jdbcTiming
element configuration overrides the requestTiming
element configuration for the slow and hung request thresholds. The jdbcTiming
element configuration can be only used to time a root-level request. For example, if a servlet request makes a JDBC query, the JDBC query cannot be timed because the servlet request is the root-level request.
Configure servlet request thresholds
The following example sets the slow and hung request thresholds for two servlets within the requestTiming
element. The servletTiming
element detects that the Arm10Servlet
servlet request is hung if the request does not complete in 20 seconds. The servlet request from the SecurityExchangeApp
application is detected as hung if the request does not complete in 2 hours:
<requestTiming slowRequestThreshold="5s" hungRequestThreshold="5m">
<servletTiming servletName="Arm10Servlet" hungRequestThreshold="20s"/>
<servletTiming appName="SecurityExchangeApp" hungRequestThreshold="2h"/>
</requestTiming>
The servletTiming
element configuration overrides the requestTiming
element configuration for the slow and hung request thresholds. The servletTiming
element configuration can be only used to time a root-level request.
Control thread dump collection when hung requests are detected
When the Request Timing feature detects hung requests, thread dumps are generated that contain the details of the events within the request. This collection of thread dumps can cause slower application performance. To control the collection of thread dumps, you can set the enableThreadDumps
attribute to false
in the requestTiming
element, as shown in the following example:
<requestTiming includeContextInfo="true" slowRequestThreshold="120s" hungRequestThreshold="10s" sampleRate="1" enableThreadDumps="false"></requestTiming>
When you set the enableThreadDumps
attribute to false
, thread dumps are not generated by hung requests. If the enableThreadDumps
attribute is set to true or is not specified at all, thread dumps are generated.
You can also configure the enableThreadDumps
attribute in an embedded servletTiming
or jdbcTiming
element. In the following example, the enableThreadDumps
attribute is set to false
in the servletTiming
element so no thread dumps are generated for the myApp
application:
<requestTiming includeContextInfo="true" slowRequestThreshold="120s" hungRequestThreshold="10s" sampleRate="1">
<servletTiming appName="MyApp" servletName="MyServletApp" slowRequestThreshold="100s" hungRequestThreshold="5s" enableThreadDumps="false"/>
</requestTiming>`