-
Notifications
You must be signed in to change notification settings - Fork 207
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 metrics for the opensearch source #3304
Add metrics for the opensearch source #3304
Conversation
Signed-off-by: Taylor Gray <[email protected]>
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.
Looks good. I think we should try to simplify the timer lambdas. Aside from that, you can take or leave the others.
@@ -102,17 +106,23 @@ public void run() { | |||
sourceCoordinator, | |||
indexPartition.get()); | |||
|
|||
processIndex(indexPartition.get(), acknowledgementSet.getLeft()); | |||
openSearchSourcePluginMetrics.getIndexProcessingTimeTimer().recordCallable(() -> { |
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.
Can you use Timer::record
which takes a Runnable
instead? This can let you use a lambda and avoid the return
statement.
openSearchSourcePluginMetrics.getIndexProcessingTimeTimer()
.recordCallable(() -> processIndex(indexPartition.get(), acknowledgementSet.getLeft()));
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.
Nice will do
private ExecutorService executorService; | ||
|
||
@BeforeEach | ||
void setup() { | ||
executorService = Executors.newSingleThreadExecutor(); | ||
lenient().when(openSearchSourceConfiguration.isAcknowledgmentsEnabled()).thenReturn(false); | ||
lenient().when(openSearchSourcePluginMetrics.getDocumentsProcessedCounter()).thenReturn(documentsProcessedCounter); |
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.
It might be a good idea to make the mocks themselves lenient. Then you can simplify this part.
@Mock(lenient = true)
indexProcessingTimeTimer = pluginMetrics.timer(INDEX_PROCESSING_TIME_ELAPSED); | ||
} | ||
|
||
public Counter getDocumentsProcessedCounter() { |
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.
An alternative design would be to increment from this class itself.
public void incrementDocumentsProcessedCounter()
Also, compare to the Law of Demeter - https://en.wikipedia.org/wiki/Law_of_Demeter
I'm ok with this either way though.
From the perspective of this class, reading the counters isn't really something it is trying to provide. It expects that its caller is just incrementing.
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.
That does make sense
Signed-off-by: Taylor Gray <[email protected]>
Add metrics for the opensearch source Signed-off-by: Taylor Gray <[email protected]>
Description
Adds the following metrics for the opensearch source
Counters
Timer
Issues Resolved
Related to #1985
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.