Add request latency (duration) to the httpd_log
In the sshd_log we have duration and in the httpd_log we do not. This
change fixes this asymmetry and adds useful info in the httpd_log.
Change-Id: I8483ea55d05f3fb4038e676df3301c2f96138fe1
diff --git a/java/com/google/gerrit/pgm/http/jetty/HttpLog.java b/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
index b7ec2be..dab9d7e 100644
--- a/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
+++ b/java/com/google/gerrit/pgm/http/jetty/HttpLog.java
@@ -45,6 +45,7 @@
protected static final String P_PROTOCOL = "Version";
protected static final String P_STATUS = "Status";
protected static final String P_CONTENT_LENGTH = "Content-Length";
+ protected static final String P_LATENCY = "Latency";
protected static final String P_REFERER = "Referer";
protected static final String P_USER_AGENT = "User-Agent";
@@ -94,6 +95,7 @@
set(event, P_PROTOCOL, req.getProtocol());
set(event, P_STATUS, rsp.getStatus());
set(event, P_CONTENT_LENGTH, rsp.getContentCount());
+ set(event, P_LATENCY, System.currentTimeMillis() - req.getTimeStamp());
set(event, P_REFERER, req.getHeader("Referer"));
set(event, P_USER_AGENT, req.getHeader("User-Agent"));
diff --git a/java/com/google/gerrit/pgm/http/jetty/HttpLogLayout.java b/java/com/google/gerrit/pgm/http/jetty/HttpLogLayout.java
index 2eea88d..bd7d998 100644
--- a/java/com/google/gerrit/pgm/http/jetty/HttpLogLayout.java
+++ b/java/com/google/gerrit/pgm/http/jetty/HttpLogLayout.java
@@ -67,6 +67,9 @@
opt(buf, event, HttpLog.P_CONTENT_LENGTH);
buf.append(' ');
+ opt(buf, event, HttpLog.P_LATENCY);
+
+ buf.append(' ');
dq_opt(buf, event, HttpLog.P_REFERER);
buf.append(' ');