-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add StatisticsCollector to Options for custom statistics tracking #964
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9e3067
Add StatisticsCollector to Options for custom statistics tracking
johnlcox 5cc16e9
Split out separate lock for readStats/writeStats
johnlcox f52f37e
Reorganize and document advanced stat tracking
johnlcox 7bc524b
Add statistics javadoc
johnlcox b12325b
Remove TODO and change lock usage in toString
johnlcox e210d35
Merge branch 'main' into statistics-collector
scottf 7b82716
Merge branch 'main' into statistics-collector
scottf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Copyright 2023 The NATS Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at: | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package io.nats.client; | ||
|
||
/** | ||
* 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(); | ||
|
||
/** | ||
* Increments the total number of times this connection has tried to reconnect. | ||
*/ | ||
void incrementReconnects(); | ||
|
||
/** | ||
* Increments the total number of messages dropped by this connection across all slow consumers. | ||
*/ | ||
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(); | ||
|
||
/** | ||
* Increments the total number of duplicate replies received by this connection. | ||
* <p> | ||
* NOTE: This is only counted if advanced stats are enabled. | ||
*/ | ||
void incrementDuplicateRepliesReceived(); | ||
|
||
/** | ||
* Increments the total number of orphan replies received by this connection. | ||
* <p> | ||
* NOTE: This is only counted if advanced stats are enabled. | ||
*/ | ||
void incrementOrphanRepliesReceived(); | ||
|
||
/** | ||
* Increments the total number of messages that have come in to this connection. | ||
*/ | ||
void incrementInMsgs(); | ||
|
||
/** | ||
* Increments the total number of messages that have gone out of this connection. | ||
*/ | ||
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(); | ||
|
||
/** | ||
* Registers a Socket read by this connection. | ||
* <p> | ||
* NOTE: Implementations should only count this if advanced stats are enabled. | ||
*/ | ||
void registerRead(long bytes); | ||
|
||
/** | ||
* Registers a Socket write by this connection. | ||
* <p> | ||
* NOTE: Implementations should only count this if advanced stats are enabled. | ||
*/ | ||
void registerWrite(long bytes); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, all orphan counter was being incremented for every duplicate or orphan when
advancedTracking
was not enabled. Does this change to first check theadvancedTracking
flag and only when enabled increment duplicate or orphan replies.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is some weird original code, and I'm to blame, sigh. This change is good.