Skip to content

Commit cb7f99a

Browse files
committed
Polish "Measure with nanoseconds in HttpExchangeTracer"
See gh-22266
1 parent d72f513 commit cb7f99a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private Map<String, List<String>> getHeadersIfIncluded(Include include,
103103
}
104104

105105
private long calculateTimeTaken(HttpTrace trace) {
106-
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - trace.getNanoTime());
106+
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - trace.getStartNanoTime());
107107
}
108108

109109
private final class FilteredTraceableRequest implements TraceableRequest {

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class HttpTrace {
4646

4747
private volatile Long timeTaken;
4848

49-
private final transient long nanoTime;
49+
private final long startNanoTime;
5050

5151
/**
5252
* Creates a fully-configured {@code HttpTrace} instance. Primarily for use by
@@ -69,13 +69,13 @@ public HttpTrace(Request request, Response response, Instant timestamp, Principa
6969
this.principal = principal;
7070
this.session = session;
7171
this.timeTaken = timeTaken;
72-
this.nanoTime = 0;
72+
this.startNanoTime = 0;
7373
}
7474

7575
HttpTrace(TraceableRequest request) {
7676
this.request = new Request(request);
7777
this.timestamp = Instant.now();
78-
this.nanoTime = System.nanoTime();
78+
this.startNanoTime = System.nanoTime();
7979
}
8080

8181
public Instant getTimestamp() {
@@ -122,8 +122,8 @@ void setTimeTaken(long timeTaken) {
122122
this.timeTaken = timeTaken;
123123
}
124124

125-
long getNanoTime() {
126-
return this.nanoTime;
125+
long getStartNanoTime() {
126+
return this.startNanoTime;
127127
}
128128

129129
/**

0 commit comments

Comments
 (0)