Skip to content

feat(spring): [Queue Instrumentation 41] Add Spring Boot 2 Kafka tracing#5352

Merged
adinauer merged 7 commits intofeat/queue-instrumentationfrom
feat/queue-instrumentation-spring-boot-2
May 6, 2026
Merged

feat(spring): [Queue Instrumentation 41] Add Spring Boot 2 Kafka tracing#5352
adinauer merged 7 commits intofeat/queue-instrumentationfrom
feat/queue-instrumentation-spring-boot-2

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 30, 2026

PR Stack (Queue Instrumentation)


📜 Description

Ports the Spring Boot 3 Kafka queue tracing stack changes to Spring Boot 2 as one PR.

This adds Spring Kafka support to the Spring 5 module, wires it into the Spring Boot 2 auto-configuration, and adds Boot 2 sample/system-test coverage for the regular, OTel agent, and OTel no-agent samples.

It also adds Cursor rules for queue tracing so future agent work has a high-level reference for how Sentry Queues data is produced by the Java SDK.

💡 Motivation and Context

The queue instrumentation stack added Kafka tracing for newer Spring Boot generations. Spring Boot 2 uses the Spring 5 module, so it needs the same Kafka producer/consumer bean post-processors and auto-configuration in the Boot 2 integration.

The new rules file documents when to load queue-specific guidance and summarizes the relationship between Sentry Queues, queue spans, Kafka instrumentation, and Spring Kafka auto-instrumentation.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry-spring:test --tests '*Kafka*' :sentry-spring-boot:test --tests '*Kafka*'
  • ./gradlew :sentry-samples:sentry-samples-spring-boot:compileJava :sentry-samples:sentry-samples-spring-boot:compileTestKotlin :sentry-samples:sentry-samples-spring-boot-opentelemetry:compileJava :sentry-samples:sentry-samples-spring-boot-opentelemetry:compileTestKotlin :sentry-samples:sentry-samples-spring-boot-opentelemetry-noagent:compileJava :sentry-samples:sentry-samples-spring-boot-opentelemetry-noagent:compileTestKotlin

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

None.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

adinauer and others added 2 commits April 29, 2026 13:54
Port Kafka queue tracing to the Spring and Spring Boot 2 modules.

Add Spring Kafka bean post-processors, Boot 2 auto-configuration, and matching sample system-test coverage.

Co-Authored-By: Claude <noreply@anthropic.com>
Document when to load queue-specific Cursor rules and summarize how Sentry Queues data is produced by the Java SDK Kafka instrumentation.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- [Queue Instrumentation 41] Add Spring Boot 2 Kafka tracing ([#5352](https://github.com/getsentry/sentry-java/pull/5352))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against a4b2016

This was referenced Apr 30, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 30, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.37.1 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 373.53 ms 448.00 ms 74.47 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/queue-instrumentation-spring-boot-4

Startup times

Revision Plain With Sentry Diff
ce27249 350.50 ms 432.16 ms 81.66 ms
89b8db0 377.17 ms 429.49 ms 52.32 ms
1a9b19e 323.42 ms 368.73 ms 45.31 ms

App size

Revision Plain With Sentry Diff
ce27249 0 B 0 B 0 B
89b8db0 0 B 0 B 0 B
1a9b19e 0 B 0 B 0 B

Previous results on branch: feat/queue-instrumentation-spring-boot-2

Startup times

Revision Plain With Sentry Diff
6432a3a 345.23 ms 421.67 ms 76.44 ms
ccba042 319.40 ms 359.81 ms 40.41 ms
c1fb851 446.80 ms 553.50 ms 106.70 ms

App size

Revision Plain With Sentry Diff
6432a3a 0 B 0 B 0 B
ccba042 0 B 0 B 0 B
c1fb851 0 B 0 B 0 B

adinauer and others added 3 commits May 5, 2026 13:43
Simplify Spring Kafka test interceptors and cover intercepting records without a consumer.

Co-Authored-By: Claude <noreply@anthropic.com>
Base automatically changed from feat/queue-instrumentation-spring-boot-4 to feat/queue-instrumentation May 6, 2026 04:13
@adinauer adinauer marked this pull request as ready for review May 6, 2026 04:36
@adinauer adinauer requested review from markushi and romtsn as code owners May 6, 2026 04:36
@adinauer adinauer merged commit 5a245f0 into feat/queue-instrumentation May 6, 2026
65 of 67 checks passed
@adinauer adinauer deleted the feat/queue-instrumentation-spring-boot-2 branch May 6, 2026 04:37
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a4b2016. Configure here.

} catch (Throwable t) {
scopes.getOptions().getLogger().log(SentryLevel.ERROR, "Unable to wrap Kafka consumer.", t);
}
return delegateIntercept(record, consumer);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Filtered records leave tracing open

Medium Severity

The intercept method starts a Sentry transaction. When the delegate filters a record by returning null, Spring Kafka skips success and failure calls. This leaves the Sentry transaction and its scope active in the currentContext (ThreadLocal), causing resource leaks.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a4b2016. Configure here.

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.

2 participants