Skip to content
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

Merged
merged 2 commits into from
Sep 6, 2023

Conversation

graytaylor0
Copy link
Member

@graytaylor0 graytaylor0 commented Sep 1, 2023

Description

Adds the following metrics for the opensearch source

Counters

  • documentsProcessed
  • indicesProcessed
  • processingErrors

Timer

  • indexProcessingTime

Issues Resolved

Related to #1985

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

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.

Copy link
Member

@dlvenable dlvenable left a 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(() -> {
Copy link
Member

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()));

Copy link
Member Author

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);
Copy link
Member

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() {
Copy link
Member

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.

Copy link
Member Author

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]>
@dlvenable dlvenable merged commit eff31fe into opensearch-project:main Sep 6, 2023
24 checks passed
asifsmohammed pushed a commit to asifsmohammed/data-prepper that referenced this pull request Sep 27, 2023
Add metrics for the opensearch source

Signed-off-by: Taylor Gray <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants