From cb7f99ad72668d8b70ec9385fd9b924cf57062f8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Jul 2020 10:02:09 +0100 Subject: [PATCH] Polish "Measure with nanoseconds in HttpExchangeTracer" See gh-22266 --- .../boot/actuate/trace/http/HttpExchangeTracer.java | 2 +- .../boot/actuate/trace/http/HttpTrace.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java index 37b649cd34..97917c0cf5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java @@ -103,7 +103,7 @@ public class HttpExchangeTracer { } 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 { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java index 8567a90847..1341ae9fab 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java @@ -46,7 +46,7 @@ public final class HttpTrace { private volatile Long timeTaken; - private final transient long nanoTime; + private final long startNanoTime; /** * Creates a fully-configured {@code HttpTrace} instance. Primarily for use by @@ -69,13 +69,13 @@ public final class HttpTrace { this.principal = principal; this.session = session; this.timeTaken = timeTaken; - this.nanoTime = 0; + this.startNanoTime = 0; } HttpTrace(TraceableRequest request) { this.request = new Request(request); this.timestamp = Instant.now(); - this.nanoTime = System.nanoTime(); + this.startNanoTime = System.nanoTime(); } public Instant getTimestamp() { @@ -122,8 +122,8 @@ public final class HttpTrace { this.timeTaken = timeTaken; } - long getNanoTime() { - return this.nanoTime; + long getStartNanoTime() { + return this.startNanoTime; } /**