open-telemetry / open-telemetry/opentelemetry-java-instrumentation
feat(spring-cloud-aws): instrument onMessage(Collection<Message<T>>) for batch consumption
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Is your feature request related to a problem? Please describe.
When using Spring Cloud AWS 3.0 SQS listeners, the Java agent successfully instruments single message consumption (onMessage(Message<T> message)). However, batch consumption using onMessage(Collection<Message<T>> messages) is currently not instrumented. This leads to missing trace contexts and broken distributed traces when an application processes messages in batches.
This limitation is noted as a TODO in the MessagingMessageListenerAdapterInstrumentation.java file.
Describe the solution you'd like
Update the MessagingMessageListenerAdapterInstrumentation to also match and apply advice to the batch consumption method: onMessage(Collection<Message<T>> messages).
The instrumentation should create a receive/process span and properly extract the trace context from the batch of messages, similarly to how it handles single messages or how other messaging instrumentations (like Kafka) handle batching.
Describe alternatives you've considered
Currently, users have to manually extract the trace context from each message in the batch and manually create their own spans, which defeats the purpose of the auto-instrumentation agent.
Additional context
Reference to the existing TODO in the codebase:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/cloud/aws/v3_0/MessagingMessageListenerAdapterInstrumentation.java#L31
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/cloud/aws/v3_0/MessagingMessageListenerAdapterInstrumentation.java, especially the referenced TODO and existing single-message advice. Compare the batch handling approach with the Kafka instrumentations. Done means the Collection<Message> onMessage method creates the appropriate receive/process span and extracts trace context from the batch, with instrumentation coverage for this path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, java, spring-boot
- Domain
- backend, observability-sre
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100