Skip to content

Commit

Permalink
Add statistics javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlcox committed Sep 1, 2023
1 parent f52f37e commit 7bc524b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/main/java/io/nats/client/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,14 @@ public Builder connectionListener(ConnectionListener listener) {
return this;
}

// TODO: Javadoc
/**
* Set the {@link StatisticsCollector StatisticsCollector} to collect connection metrics.
* <p>
* 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;
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 25 additions & 3 deletions src/main/java/io/nats/client/Statistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand All @@ -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();

/**
Expand Down Expand Up @@ -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();
}
41 changes: 40 additions & 1 deletion src/main/java/io/nats/client/StatisticsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* Information about key metrics is incremented on this collector by the connection.
* <p>
* 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();

/**
Expand All @@ -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();

/**
Expand All @@ -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();

/**
Expand Down

0 comments on commit 7bc524b

Please sign in to comment.