james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/7] james-project git commit: JAMES-2599 Publishing metrics for completable futures
Date Thu, 22 Nov 2018 10:51:38 GMT
JAMES-2599 Publishing metrics for completable futures


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/bcfb5b83
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/bcfb5b83
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/bcfb5b83

Branch: refs/heads/master
Commit: bcfb5b831b24224fa3b7faf8178c697458f4a7fd
Parents: 0ec5ccc
Author: tran tien duc <dtran@linagora.com>
Authored: Thu Nov 22 09:55:30 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Nov 22 17:50:42 2018 +0700

----------------------------------------------------------------------
 .../main/java/org/apache/james/metrics/api/MetricFactory.java  | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/bcfb5b83/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
----------------------------------------------------------------------
diff --git a/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
b/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
index a472b53..e61064e 100644
--- a/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
+++ b/metrics/metrics-api/src/main/java/org/apache/james/metrics/api/MetricFactory.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.metrics.api;
 
+import java.util.concurrent.CompletableFuture;
 import java.util.function.Supplier;
 
 public interface MetricFactory {
@@ -42,4 +43,9 @@ public interface MetricFactory {
             return null;
         });
     }
+
+    default <T> CompletableFuture<T> runPublishingTimerMetric(String name, CompletableFuture<T>
future) {
+        TimeMetric timer = timer(name);
+        return future.whenComplete((result, throwable) -> timer.stopAndPublish());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message