tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1495888 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/valves/AccessLogValve.java java/org/apache/coyote/Response.java webapps/docs/changelog.xml webapps/docs/config/valve.xml
Date Sun, 23 Jun 2013 20:25:47 GMT
Author: markt
Date: Sun Jun 23 20:25:46 2013
New Revision: 1495888

URL: http://svn.apache.org/r1495888
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55102
Add support for time to first byte to the AccessLog.
Patch by Jeremy Boynes.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/valve.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1495886

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=1495888&r1=1495887&r2=1495888&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java Sun Jun 23 20:25:46
2013
@@ -1744,6 +1744,24 @@ public class AccessLogValve extends Valv
     }
 
     /**
+     * write time until first byte is written (commit time) in millis - %F
+     */
+    protected static class FirstByteTimeElement implements AccessLogElement {
+        @Override
+        public void addElement(StringBuilder buf, Date date, Request request,
+                Response response, long time) {
+            long commitTime = response.getCoyoteResponse().getCommitTime();
+            if (commitTime == -1) {
+                buf.append('-');
+            } else {
+                long delta =
+                        commitTime - request.getCoyoteRequest().getStartTime();
+                buf.append(Long.toString(delta));
+            }
+        }
+    }
+
+    /**
      * write Query string (prepended with a '?' if it exists) - %q
      */
     protected static class QueryElement implements AccessLogElement {
@@ -2055,6 +2073,8 @@ public class AccessLogValve extends Valv
             return new ByteSentElement(false);
         case 'D':
             return new ElapsedTimeElement(true);
+        case 'F':
+            return new FirstByteTimeElement();
         case 'h':
             return new HostElement();
         case 'H':

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java?rev=1495888&r1=1495887&r2=1495888&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/Response.java Sun Jun 23 20:25:46 2013
@@ -101,6 +101,7 @@ public final class Response {
 
     // General informations
     private long contentWritten = 0;
+    private long commitTime = -1;
 
     /**
      * Holds request error exception.
@@ -213,9 +214,20 @@ public final class Response {
 
 
     public void setCommitted(boolean v) {
+        if (v && !this.commited) {
+            this.commitTime = System.currentTimeMillis();
+        }
         this.commited = v;
     }
 
+    /**
+     * Return the time the response was committed (based on System.currentTimeMillis).
+     *
+     * @return the time the response was committed
+     */
+    public long getCommitTime() {
+        return commitTime;
+    }
 
     // -----------------Error State --------------------
 
@@ -351,7 +363,7 @@ public final class Response {
      */
     public void sendHeaders() {
         action(ActionCode.COMMIT, this);
-        commited = true;
+        setCommitted(true);
     }
 
 
@@ -519,6 +531,7 @@ public final class Response {
         status = 200;
         message = null;
         commited = false;
+        commitTime = -1;
         errorException = null;
         headers.clear();
 

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1495888&r1=1495887&r2=1495888&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Jun 23 20:25:46 2013
@@ -82,6 +82,10 @@
         <bug>55110</bug>: Small performance improvements. Patches provided by
         Adrian Nistor. (markt)
       </fix>
+      <add>
+        <bug>55102</bug>: Add support for time to first byte in the
+        AccessLogValve. Patch provided by Jeremy Boynes. (markt)
+      </add>
       <fix>
         <bug>55125</bug>: If the Server container fails to start, don't allow
         the Catalina wrapper to start (used when running from the command line

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/valve.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/valve.xml?rev=1495888&r1=1495887&r2=1495888&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/valve.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/valve.xml Sun Jun 23 20:25:46 2013
@@ -273,6 +273,7 @@
     <li><b>%v</b> - Local server name</li>
     <li><b>%D</b> - Time taken to process the request, in millis</li>
     <li><b>%T</b> - Time taken to process the request, in seconds</li>
+    <li><b>%F</b> - Time taken to commit the response, in millis</li>
     <li><b>%I</b> - Current request thread name (can compare later with
stacktraces)</li>
     </ul>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message