diff --git a/broker/pom.xml b/broker/pom.xml
index 10d35fe4..ac702cfb 100644
--- a/broker/pom.xml
+++ b/broker/pom.xml
@@ -113,7 +113,14 @@
2.0.0-SNAPSHOT
-
+
+
+ org.hdrhistogram
+ HdrHistogram
+ 2.1.4
+
+
+
junit
junit
@@ -126,7 +133,7 @@
robot.junit
0.0.0.12
test
-
+
diff --git a/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java b/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java
index 0cff3ca8..9dd2cdb8 100644
--- a/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java
+++ b/broker/src/main/java/org/eclipse/moquette/spi/impl/SimpleMessaging.java
@@ -36,6 +36,7 @@ import org.eclipse.moquette.server.IAuthenticator;
import org.eclipse.moquette.server.ServerChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.HdrHistogram.Histogram;
/**
*
@@ -67,6 +68,8 @@ public class SimpleMessaging implements IMessaging, EventHandler {
private final AnnotationSupport annotationSupport = new AnnotationSupport();
CountDownLatch m_stopLatch;
+
+ Histogram histogram = new Histogram(5);
private SimpleMessaging() {
}
@@ -153,7 +156,10 @@ public class SimpleMessaging implements IMessaging, EventHandler {
ServerChannel session = ((ProtocolEvent) evt).getSession();
AbstractMessage message = ((ProtocolEvent) evt).getMessage();
try {
+ long startTime = System.nanoTime();
annotationSupport.dispatch(session, message);
+ long delay = System.nanoTime() - startTime;
+ histogram.recordValue(delay);
} catch (Throwable th) {
LOG.error("Grave error processing the message {} for {}", message, session, th);
}
@@ -194,5 +200,8 @@ public class SimpleMessaging implements IMessaging, EventHandler {
subscriptions = null;
m_stopLatch.countDown();
+
+ //log metrics
+ histogram.outputPercentileDistribution(System.out, 1000.0);
}
}