Mark,

On 9/22/25 3:46 PM, [email protected] wrote:
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
      new a13c5d3326 Record the instant the request processing starts.
a13c5d3326 is described below

commit a13c5d33265b7779dce46c4a3155399eaa8820c7
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Sep 22 20:44:44 2025 +0100

     Record the instant the request processing starts.
---
  java/org/apache/coyote/Request.java | 9 +++++++++
  1 file changed, 9 insertions(+)

diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 2252e126e0..573e524fad 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -20,6 +20,7 @@ import java.io.IOException;
  import java.io.StringReader;
  import java.io.UnsupportedEncodingException;
  import java.nio.charset.Charset;
+import java.time.Instant;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Objects;
@@ -163,6 +164,7 @@ public final class Request {
      private long bytesRead = 0;
      // Time of the request - useful to avoid repeated calls to 
System.currentTime
      private long startTimeNanos = -1;
+    private Instant startInstant = null;
      private long threadId = 0;
      private int available = 0;
@@ -764,10 +766,16 @@ public final class Request {
      @Deprecated
      public void setStartTimeNanos(long startTimeNanos) {
          this.startTimeNanos = startTimeNanos;
+        startInstant = Instant.now();
      }

As this point, you can change getStartTimeNanos to:

return startInstant.getEpochSecond() * 1_000_000_000L + startInstant.getNano();

That trades computation for assignment, so it may not be worth it.

      public void markStartTime() {
          startTimeNanos = System.nanoTime();
+        startInstant = Instant.now();
+    }
+
+    public Instant getStartInstant() {
+        return startInstant;
      }
public long getThreadId() {
@@ -878,6 +886,7 @@ public final class Request {
          allDataReadEventSent.set(false);
startTimeNanos = -1;
+        startInstant = null;
          threadId = 0;
if (hook instanceof NonPipeliningProcessor) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to