diff --git a/src/main/java/io/nats/client/Options.java b/src/main/java/io/nats/client/Options.java index cd708a8f5..c4c2dcc97 100644 --- a/src/main/java/io/nats/client/Options.java +++ b/src/main/java/io/nats/client/Options.java @@ -1335,7 +1335,14 @@ public Builder connectionListener(ConnectionListener listener) { return this; } - // TODO: Javadoc + /** + * Set the {@link StatisticsCollector StatisticsCollector} to collect connection metrics. + *
+ * If not set, then a default implementation will be used. + * + * @param collector the new StatisticsCollector for this connection. + * @return the Builder for chaining + */ public Builder statisticsCollector(StatisticsCollector collector) { this.statisticsCollector = collector; return this; @@ -1706,6 +1713,9 @@ public ConnectionListener getConnectionListener() { return this.connectionListener; } + /** + * @return the statistics collector, or null, see {@link Builder#statisticsCollector(StatisticsCollector) statisticsCollector()} in the builder doc + */ public StatisticsCollector getStatisticsCollector() { return this.statisticsCollector; } diff --git a/src/main/java/io/nats/client/Statistics.java b/src/main/java/io/nats/client/Statistics.java index 8e9d014cb..73957e9cc 100644 --- a/src/main/java/io/nats/client/Statistics.java +++ b/src/main/java/io/nats/client/Statistics.java @@ -21,8 +21,9 @@ */ public interface Statistics { - // TODO: Javadoc -- methods and indicate which stats are advanced stats - + /** + * @return the total number of pings that have been sent from this connection. + */ long getPings(); /** @@ -35,14 +36,29 @@ public interface Statistics { */ long getDroppedCount(); + /** + * @return the total number of op +OKs received by this connection. + */ long getOKs(); + /** + * @return the total number of op -ERRs received by this connection. + */ long getErrs(); + /** + * @return the total number of exceptions seen by this connection. + */ long getExceptions(); + /** + * @return the total number of requests sent by this connection. + */ long getRequestsSent(); + /** + * @return the total number of replies received by this connection. + */ long getRepliesReceived(); /** @@ -75,11 +91,17 @@ public interface Statistics { long getInBytes(); /** - * @return the total number of message bytes that have gone out of to this connection. + * @return the total number of message bytes that have gone out of this connection. */ long getOutBytes(); + /** + * @return the total number of outgoing message flushes by this connection. + */ long getFlushCounter(); + /** + * @return the count of outstanding of requests from this connection. + */ long getOutstandingRequests(); } diff --git a/src/main/java/io/nats/client/StatisticsCollector.java b/src/main/java/io/nats/client/StatisticsCollector.java index 736a2e9f2..b7de6514d 100644 --- a/src/main/java/io/nats/client/StatisticsCollector.java +++ b/src/main/java/io/nats/client/StatisticsCollector.java @@ -13,13 +13,22 @@ package io.nats.client; -// TODO: Javadoc -- class and methods and indicate which stats are advanced stats +/** + * A collector for connection metrics. + *
+ * Information about key metrics is incremented on this collector by the connection. + *
+ * See {@link Statistics} for accessing the collected metrics. + */ public interface StatisticsCollector extends Statistics { /** * Sets whether advanced stats are/should be tracked. */ void setAdvancedTracking(boolean trackAdvanced); + /** + * Increments the total number of pings that have been sent from this connection. + */ void incrementPingCount(); /** @@ -32,14 +41,29 @@ public interface StatisticsCollector extends Statistics { */ void incrementDroppedCount(); + /** + * Increments the total number of op +OKs received by this connection. + */ void incrementOkCount(); + /** + * Increments the total number of op -ERRs received by this connection. + */ void incrementErrCount(); + /** + * Increments the total number of exceptions seen by this connection. + */ void incrementExceptionCount(); + /** + * Increments the total number of requests sent by this connection. + */ void incrementRequestsSent(); + /** + * Increments the total number of replies received by this connection. + */ void incrementRepliesReceived(); /** @@ -66,14 +90,29 @@ public interface StatisticsCollector extends Statistics { */ void incrementOutMsgs(); + /** + * Increment the total number of message bytes that have come in to this connection. + */ void incrementInBytes(long bytes); + /** + * Increment the total number of message bytes that have gone out of this connection. + */ void incrementOutBytes(long bytes); + /** + * Increment the total number of outgoing message flushes by this connection. + */ void incrementFlushCounter(); + /** + * Increments the count of outstanding of requests from this connection. + */ void incrementOutstandingRequests(); + /** + * Decrements the count of outstanding of requests from this connection. + */ void decrementOutstandingRequests(); /**