summaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorgjoranv <gjoranv@gmail.com>2017-11-13 14:38:16 +0100
committerGitHub <noreply@github.com>2017-11-13 14:38:16 +0100
commit09bb85ef07574fb6d6cd8e7fb100bd1ef0d55f79 (patch)
treeaa457ee802a408fedf1b349d71cf62ac850d77cc /jdisc_core
parent372b70b09f7abba1aafe4931b44f01d7f9415d4a (diff)
parent89d6180fed2782b74794ec511f273468a3285353 (diff)
Merge pull request #4095 from vespa-engine/arnej/add-jdisc-handler-metrics
Arnej/add jdisc handler metrics
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/Request.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
index 489a4c3dc10..7a76c588fb4 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java
@@ -287,7 +287,7 @@ public class Request extends AbstractResource {
}
/**
- * <p>Returns the allocated number of milliseconds that this Request is allowed to exist. If no timeout has been set
+ * <p>Returns the allocated number of time units that this Request is allowed to exist. If no timeout has been set
* for this Request, this method returns <em>null</em>.</p>
*
* @param unit The unit to return the timeout in.
@@ -306,7 +306,7 @@ public class Request extends AbstractResource {
* <em>null</em>.</p>
*
* @param unit The unit to return the time in.
- * @return The number of milliseconds left until this Request times out, or <em>null</em>.
+ * @return The number of time units left until this Request times out, or <em>null</em>.
*/
public Long timeRemaining(TimeUnit unit) {
if (timeout == null) {
@@ -316,6 +316,16 @@ public class Request extends AbstractResource {
}
/**
+ * <p>Returns the time that this Request has existed so far.
+ *
+ * @param unit The unit to return the time in.
+ * @return The number of time units elapsed since this Request was created.
+ */
+ public long timeElapsed(TimeUnit unit) {
+ return unit.convert(container().currentTimeMillis() - creationTime, TimeUnit.MILLISECONDS);
+ }
+
+ /**
* <p>Returns the time at which this Request was created. This is whatever value was returned by {@link
* Timer#currentTimeMillis()} when constructing this.</p>
*