Skip to content

fix(spring): [Cache Tracing 11] Skip cache span data when child span is NoOp#5192

Draft
adinauer wants to merge 1 commit intofeat/cache-tracing-spring-boot-2from
fix/cache-tracing-noop-span
Draft

fix(spring): [Cache Tracing 11] Skip cache span data when child span is NoOp#5192
adinauer wants to merge 1 commit intofeat/cache-tracing-spring-boot-2from
fix/cache-tracing-noop-span

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 13, 2026

PR Stack (Cache Tracing)

  • #5172 — Add SentryCacheWrapper and SentryCacheManagerWrapper
  • #5173 — Add enableCacheTracing option
  • #5174 — Add BeanPostProcessor and auto-configuration
  • #5175 — Add cache tracing e2e sample
  • #5179 — Add SentryJCacheWrapper for JCache (JSR-107)
  • #5182 — Add JCache console sample
  • #5183 — Add cache tracing to all Spring Boot 4 samples
  • #5184 — Add retrieve() overrides for reactive/async cache support
  • #5190 — Port cache tracing to Spring Boot 3 Jakarta + samples
  • #5191 — Port cache tracing to Spring Boot 2 + samples
  • This PR — Skip cache span data when child span is NoOp

📜 Description

Add span.isNoOp() check after startChild() in the startSpan() helper method of all three Spring SentryCacheWrapper variants (sentry-spring, sentry-spring-7, sentry-spring-jakarta). This matches the existing pattern in SentryJCacheWrapper, which already had this check.

Without this fix, when sampling drops a span, the wrapper still sets span data (cache.key, etc.) on the noop span unnecessarily.

💡 Motivation and Context

The JCache wrapper (SentryJCacheWrapper) correctly returns null when the child span is a NoOp (e.g. due to sampling), skipping all span data decoration. The three Spring cache wrappers were missing this check, creating an inconsistency and doing unnecessary work on noop spans.

💚 How did you test it?

Code review — the change is minimal and mirrors the existing JCache pattern exactly.

📝 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 — this is a small consistency fix.

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

#skip-changelog

Add span.isNoOp() check after startChild() in all three Spring
SentryCacheWrapper variants, matching the existing pattern in
SentryJCacheWrapper. This avoids setting span data on noop spans
when sampling drops the span.

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

github-actions bot commented Mar 13, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@sentry
Copy link

sentry bot commented Mar 13, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK Size io.sentry.tests.size 8.34.1 (1) release Install Build

@github-actions
Copy link
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 325.98 ms 412.96 ms 86.98 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/cache-tracing-spring-boot-2

Startup times

Revision Plain With Sentry Diff
c3e99d4 312.46 ms 388.79 ms 76.33 ms

App size

Revision Plain With Sentry Diff
c3e99d4 0 B 0 B 0 B

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.

1 participant