Skip to content

feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … #19053

Open
Aryainguz wants to merge 20 commits into
open-telemetry:mainfrom
Aryainguz:fix-aws-sqs-batch
Open

feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … #19053
Aryainguz wants to merge 20 commits into
open-telemetry:mainfrom
Aryainguz:fix-aws-sqs-batch

Conversation

@Aryainguz

@Aryainguz Aryainguz commented Jun 19, 2026

Copy link
Copy Markdown

Fixes #19052

Copilot AI review requested due to automatic review settings June 19, 2026 22:43
@Aryainguz Aryainguz requested a review from a team as a code owner June 19, 2026 22:43
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 19, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Aryainguz / name: aryainguz (4115c62)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Aryainguz Aryainguz marked this pull request as draft June 19, 2026 22:45
@Aryainguz Aryainguz changed the title feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … 19052 Jun 19, 2026
@Aryainguz Aryainguz changed the title feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … 19052 feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) … Jun 19, 2026
@Aryainguz Aryainguz force-pushed the fix-aws-sqs-batch branch 3 times, most recently from 99088d1 to 6f62474 Compare June 19, 2026 23:11
@Aryainguz Aryainguz force-pushed the fix-aws-sqs-batch branch 4 times, most recently from 72eb903 to 6c901e8 Compare June 19, 2026 23:32
@Aryainguz Aryainguz force-pushed the fix-aws-sqs-batch branch from 6c901e8 to 1a51d04 Compare June 19, 2026 23:56
@Aryainguz Aryainguz marked this pull request as ready for review June 20, 2026 00:23
@Aryainguz Aryainguz requested a review from Copilot June 20, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

List<String> result = messageFuture.get(10, SECONDS);
assertThat(result).containsExactly(messageContent);

testing.waitAndAssertTraces(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't look right. The trace structure does not follow what other instrumentations use for batch sending and receiving. There are no receive/process spans. The callback span on the receiver side is in the same trace as the producer which is unexpected. Usually the batch scenarios create separate traces for receiver and producer that are connected via span links. I guess if the batch receive really receives only 1 message it is possible to model this in a single trace but if there are multiple messages then it won't be possible. Image that batch receive receives 2 message A and B that are part of different traces. I don't know by heart whether we have any instrumentations that would change the trace structure of batch receives depending on whether 1 ore more messages were received.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for review, @laurit You were right.

The issue was that the code was entirely skipping the creation of the process span for batch handlers.

To fix this, I updated SpringAwsUtil to explicitly create a proper CONSUMER process span when handling batches, and updated the acknowledgement step to properly link back to that trace. The tests have been updated to verify the new trace structure and everything is passing locally. Please review again and let me know what you think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would expect a trace structure similar to

where producer and receiver are in separate traces.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

}
}

static volatile Consumer<List<String>> batchMessageHandler;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've updated the implementation to explicitly model the single-span batch behavior with correct batch semantics. The batch process span now includes the messaging.batch.message_count attribute and is linked to the producer spans of all messages in the batch. I've also added multi-message test coverage to validate this regression doesn't happen.

if (messages.isEmpty()) {
return null;
}
Message<?> message = messages.iterator().next();

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.

AI generated comment (I have not verified it) --

[General] handleBatch() starts a process span from only messages.iterator().next(), so a real batch with multiple SQS messages only gets tracing context/process telemetry for the first message. The AWS SDK TracingList path normally traces each received SQS message as it is processed, and this instrumentation explicitly disables that iterator tracing during Spring conversion so the listener advice can do the tracing later. With the current implementation, messages after the first are effectively dropped from the process-span side of the instrumentation, and user callback work is parented only to the first message’s span. The new test sends a singleton batch, so it would not catch this regression. Please either trace each message in the collection or make the single-span batch behavior explicit with correct batch semantics and multi-message test coverage.

@Aryainguz Aryainguz requested a review from Copilot June 27, 2026 08:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

This PR has review comments. Review suggestions, whether from maintainers or automated reviewers, aren't always correct or required. Please evaluate each comment on its merits, then make sure each thread has a clear outcome.

For example, link to the commit if you applied a suggestion, explain why it wasn't applied, or ask a follow-up question.

Automation flags a PR for human review once every review thread has a reply or is marked as resolved.

Status across open PRs is visible on the pull request dashboard.

@Aryainguz Aryainguz marked this pull request as draft June 27, 2026 11:07
@Aryainguz Aryainguz marked this pull request as ready for review June 27, 2026 16:32
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.

feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) for batch consumption

4 participants