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

Report SQS message delay immediately after message is received, and as 0 when there are no messages found in queue #5333

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

graytaylor0
Copy link
Member

@graytaylor0 graytaylor0 commented Jan 15, 2025

Description

When there are no messages pulled from the queue, the sqsMessageDelay metric is not being reported. When there are no messages pulled from the queue, that means the queue is empty and this can be reported as a delay of 0.

Additionally, the sqsMessageDelay metric is currently reported at the time the S3 object is processed. This means that with maximum_messages at 10, for example, the 10th message will report high delay because it may take a long time for the previous 9 objects to be processed.

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.

@graytaylor0 graytaylor0 changed the title Report SQS message delay as 0 when there are no messages found in queue Report SQS message delay immediately after message is received, and as 0 when there are no messages found in queue Jan 15, 2025
dlvenable
dlvenable previously approved these changes Jan 15, 2025
@@ -228,6 +231,10 @@ && isEventBridgeEventTypeCreated(parsedMessage)) {
LOG.info("Received {} messages from SQS. Processing {} messages.", s3EventNotificationRecords.size(), parsedMessagesToRead.size());

for (ParsedMessage parsedMessage : parsedMessagesToRead) {
sqsMessageDelayTimer.record(Duration.between(
Copy link
Member

Choose a reason for hiding this comment

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

This change is untested. We can use a Mockito inOrder to verify that this happens before or after a certain part in the tests. I'm guessing there is an existing test that could be updated to use inOrder to ensure this behavior remains consistent.

e.g.

InOrder inOrder = inOrder(s3Service, sqsMessageDelayTimer);
inOrder.verify(sqsMessageDelayTimer).record(...);
inOrder.verify(s3Service).addS3Object(...);

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense I can make that change

kkondaka
kkondaka previously approved these changes Jan 15, 2025
…s 0 when there are no messages found in queue

Signed-off-by: Taylor Gray <[email protected]>
@graytaylor0 graytaylor0 merged commit 8318041 into opensearch-project:main Jan 15, 2025
44 of 47 checks passed
@graytaylor0 graytaylor0 deleted the SqsMetricReport branch January 15, 2025 23: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