Skip to content

Extend spring.consume context through Spring Cloud AWS SQS error handlers#11257

Draft
ygree wants to merge 3 commits intomasterfrom
ygree/fix-11234
Draft

Extend spring.consume context through Spring Cloud AWS SQS error handlers#11257
ygree wants to merge 3 commits intomasterfrom
ygree/fix-11234

Conversation

@ygree
Copy link
Copy Markdown
Contributor

@ygree ygree commented May 1, 2026

What Does This Do

Extend spring.consume context through Spring Cloud AWS SQS error handlers

Motivation

Spring Cloud AWS SQS error handler missing trace context

Additional Notes

Ref: #11234

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@ygree ygree self-assigned this May 1, 2026
@ygree ygree added type: bug Bug report and fix inst: spring Spring instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels May 1, 2026
@ygree ygree changed the title fix: Spring Cloud AWS SQS error handler missing trace context Extend spring.consume context through Spring Cloud AWS SQS error handlers May 2, 2026
@ygree ygree marked this pull request as ready for review May 2, 2026 05:21
@ygree ygree requested a review from a team as a code owner May 2, 2026 05:21
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a2c83769c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// which is not bundled in spring-messaging but is always present when Spring Kafka is.
extraDependency 'org.reactivestreams:reactive-streams:1.0.4'
// Spring Cloud AWS error-handler instrumentations reference ListenerExecutionFailedException.
extraDependency 'io.awspring.cloud:spring-cloud-aws-sqs:3.0.1'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid gating spring-messaging on Spring Cloud AWS

In applications that use Spring Messaging/Spring Kafka but do not include spring-cloud-aws-sqs, adding this AWS dependency to the only spring-messaging muzzle directive makes the whole instrumentation safe only when AWS SQS is also present. The existing InvocableHandlerMethod/Kafka messaging instrumentation in this same module has no muzzleDirective() override, and the project docs note module directives are checked against all instrumentations by default, so non-AWS Spring Messaging apps can lose their existing spring.consume instrumentation instead of only skipping the new AWS-specific instrumenters. Split the AWS instrumenters behind their own directive/module or override muzzleDirective() so the base Spring Messaging instrumentation remains loadable without AWS.

Useful? React with 👍 / 👎.

Comment on lines 99 to +103
if (null != error) {
DECORATE.onError(span, error);
if (SpringMessageErrorHandlerHelper.isInAwsListenerInvocation()) {
SpringMessageErrorHandlerHelper.capturePendingContinuation(span);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate context for asynchronous listener failures

When an @SqsListener returns a CompletableFuture/CompletionStage that completes exceptionally after invoke returns, @Advice.Thrown error is null here, so no pending continuation is captured. Spring Cloud AWS wraps that later async failure in MessageListenerExecutionStage rather than through createListenerException, so the error handler still runs without the spring.consume context for the normal async-failure path; the added test only covers a method that throws before returning its future. Capture/attach the continuation for failed async results as well as synchronous throws.

Useful? React with 👍 / 👎.

@ygree ygree marked this pull request as draft May 2, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: spring Spring instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant