Polish "Measure with nanoseconds in HttpExchangeTracer"

See gh-22266
This commit is contained in:
Andy Wilkinson 2020-07-09 10:02:09 +01:00
parent d72f5139f1
commit cb7f99ad72
2 changed files with 6 additions and 6 deletions

View File

@ -103,7 +103,7 @@ public class HttpExchangeTracer {
} }
private long calculateTimeTaken(HttpTrace trace) { private long calculateTimeTaken(HttpTrace trace) {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - trace.getNanoTime()); return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - trace.getStartNanoTime());
} }
private final class FilteredTraceableRequest implements TraceableRequest { private final class FilteredTraceableRequest implements TraceableRequest {

View File

@ -46,7 +46,7 @@ public final class HttpTrace {
private volatile Long timeTaken; private volatile Long timeTaken;
private final transient long nanoTime; private final long startNanoTime;
/** /**
* Creates a fully-configured {@code HttpTrace} instance. Primarily for use by * Creates a fully-configured {@code HttpTrace} instance. Primarily for use by
@ -69,13 +69,13 @@ public final class HttpTrace {
this.principal = principal; this.principal = principal;
this.session = session; this.session = session;
this.timeTaken = timeTaken; this.timeTaken = timeTaken;
this.nanoTime = 0; this.startNanoTime = 0;
} }
HttpTrace(TraceableRequest request) { HttpTrace(TraceableRequest request) {
this.request = new Request(request); this.request = new Request(request);
this.timestamp = Instant.now(); this.timestamp = Instant.now();
this.nanoTime = System.nanoTime(); this.startNanoTime = System.nanoTime();
} }
public Instant getTimestamp() { public Instant getTimestamp() {
@ -122,8 +122,8 @@ public final class HttpTrace {
this.timeTaken = timeTaken; this.timeTaken = timeTaken;
} }
long getNanoTime() { long getStartNanoTime() {
return this.nanoTime; return this.startNanoTime;
} }
/** /**