Skip to content

Added metrics to SQS notification queue for S3 source#6256

Merged
dlvenable merged 1 commit into
opensearch-project:mainfrom
mzurita-amz:fix-sqs-metrics-location
Nov 13, 2025
Merged

Added metrics to SQS notification queue for S3 source#6256
dlvenable merged 1 commit into
opensearch-project:mainfrom
mzurita-amz:fix-sqs-metrics-location

Conversation

@mzurita-amz

Copy link
Copy Markdown
Contributor

Description

In PR-6248 we added SQS metrics to the Common worker. This actual worker used in S3 collection is the SqsWorker. This PR makes SQS metrics available in S3 source as well.

Also, removed IT from previous received feedback.

Issues Resolved

N/A

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.

@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch 4 times, most recently from 1165546 to 888b9ce Compare November 11, 2025 22:19
@mzurita-amz mzurita-amz marked this pull request as ready for review November 12, 2025 00:36

@viquer viquer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal change on visibilty

Comment on lines +66 to +68
public static final String SQS_MESSAGE_ACCESS_DENIED_METRIC_NAME = "sqsMessagesAccessDenied";
public static final String SQS_MESSAGE_THROTTLED_METRIC_NAME = "sqsMessagesThrottled";
public static final String SQS_QUEUE_NOT_FOUND_METRIC_NAME = "sqsQueueNotFound";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: don't need to be public.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Comment on lines +66 to +68
public static final String SQS_MESSAGE_ACCESS_DENIED_METRIC_NAME = "sqsMessagesAccessDenied";
public static final String SQS_MESSAGE_THROTTLED_METRIC_NAME = "sqsMessagesThrottled";
public static final String SQS_QUEUE_NOT_FOUND_METRIC_NAME = "sqsQueueNotFound";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

isStopped = true;
}

public void recordSqsException(final AwsServiceException e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this private.

import static org.opensearch.dataprepper.plugins.source.s3.SqsWorker.SQS_VISIBILITY_TIMEOUT_CHANGED_COUNT_METRIC_NAME;

@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will apply lenient to all mocks. Let's avoid this. You can use lenient(). on the specific metric mocks.

Relatedly, do you even need lenient in your tests? They look scoped down enough to no require it at all.

} else if (e.statusCode() == 404 ||
e instanceof QueueDoesNotExistException ||
e instanceof KmsNotFoundException) {
sqsQueueNotFoundCounter.increment();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e instanceof KmsNotFoundException do we need a new counter sqsKmsKeyNotFoundCounter ?

@mzurita-amz mzurita-amz Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On our side, aggregating into a single NotFound metric is enough. But let me know if you or David think otherwise. Or a different name for this metric.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point.

If we keep one metric, maybe rename it?

static final String SQS_QUEUE_NOT_FOUND_METRIC_NAME = "sqsQueueNotFound";

to

static final String SQS_RESOURCE_NOT_FOUND_METRIC_NAME = "sqsResourceNotFound";

@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch from 888b9ce to dd85299 Compare November 12, 2025 17:42
@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch from dd85299 to 975a52a Compare November 12, 2025 17:52
dinujoh
dinujoh previously approved these changes Nov 12, 2025
@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch 4 times, most recently from d0b5aa3 to 2051700 Compare November 12, 2025 22:50
} else if (e.statusCode() == 404 ||
e instanceof QueueDoesNotExistException ||
e instanceof KmsNotFoundException) {
sqsQueueNotFoundCounter.increment();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider renaming the variable sqsQueueNotFoundCounter to sqsResourceNotFoundCounter

dinujoh
dinujoh previously approved these changes Nov 12, 2025
dinujoh
dinujoh previously approved these changes Nov 12, 2025
@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch from 1402625 to 2f01169 Compare November 12, 2025 23:28
dlvenable
dlvenable previously approved these changes Nov 13, 2025
@dlvenable

Copy link
Copy Markdown
Member

@mzurita-amz , There are failing unit tests for the S3 source. And the DCO check is not passing. Let's address these and then we will be good to merge.

@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch from 2f01169 to 0bef3dd Compare November 13, 2025 00:19
@mzurita-amz mzurita-amz dismissed stale reviews from dlvenable and dinujoh via b354f95 November 13, 2025 02:02
@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch 2 times, most recently from b354f95 to a75d63d Compare November 13, 2025 02:15
- Add lenient mocks for SQS counter metrics initialized in SqsWorker constructor
- Fix test methods to use processSqsMessages() instead of run() to avoid infinite loops
- Ensure all SQS exception tests properly verify counter increments
- All 333 tests now pass

Signed-off-by: Manuel Mangas Zurita <mzurita@amazon.com>
@mzurita-amz mzurita-amz force-pushed the fix-sqs-metrics-location branch from a75d63d to 77897fe Compare November 13, 2025 14:15
@dlvenable dlvenable merged commit 8904048 into opensearch-project:main Nov 13, 2025
49 of 50 checks passed
@mzurita-amz mzurita-amz deleted the fix-sqs-metrics-location branch November 13, 2025 22:17
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.

4 participants