Skip to content

Commit

Permalink
KNL-80
Browse files Browse the repository at this point in the history
Patch from Stephen Marquard

The attached patch adds some debug logging to the RequestFilter to assist in the analysis of number of db queries executed per request, and elapsed time per request.

This would have no effect in production instances where debug logging for RequestFilter is not enabled.

Thanks

git-svn-id: https://source.sakaiproject.org/svn/kernel/trunk@54687 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
ieb committed Nov 27, 2008
1 parent 3077ceb commit 117fda2
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions kernel/api/src/main/java/org/sakaiproject/util/RequestFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ public void destroy()
public void doFilter(ServletRequest requestObj, ServletResponse responseObj, FilterChain chain) throws IOException,
ServletException
{
StringBuffer sb = null;
long startTime = System.currentTimeMillis();

// bind some preferences as "current"
Expand Down Expand Up @@ -563,6 +564,20 @@ public void doFilter(ServletRequest requestObj, ServletResponse responseObj, Fil
// filter the request
else
{
if (M_log.isDebugEnabled())
{
sb = new StringBuffer("http-request: ");
sb.append(req.getMethod());
sb.append(" ");
sb.append(req.getRequestURL());
if (req.getQueryString() != null)
{
sb.append("?");
sb.append(req.getQueryString());
}
M_log.debug(sb);
}

try
{
// mark the request as filtered to avoid re-filtering it later in the request processing
Expand Down Expand Up @@ -628,10 +643,10 @@ public void doFilter(ServletRequest requestObj, ServletResponse responseObj, Fil
// delete any temp files
deleteTempFiles(tempFiles);

if (M_log.isDebugEnabled())
if (M_log.isDebugEnabled() && sb != null)
{
long elapsedTime = System.currentTimeMillis() - startTime;
M_log.debug("request timing (ms): " + elapsedTime);
M_log.debug("request timing (ms): " + elapsedTime + " for " + sb);
}
}
}
Expand Down

0 comments on commit 117fda2

Please sign in to comment.