Merge "Add request latency (duration) to the httpd_log"

This commit is contained in:
David Ostrovsky
2018-11-05 10:58:53 +00:00
committed by Gerrit Code Review
2 changed files with 5 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
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 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
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"));

View File

@@ -66,6 +66,9 @@ public final class HttpLogLayout extends Layout {
buf.append(' ');
opt(buf, event, HttpLog.P_CONTENT_LENGTH);
buf.append(' ');
opt(buf, event, HttpLog.P_LATENCY);
buf.append(' ');
dq_opt(buf, event, HttpLog.P_REFERER);