Skip to content

feat(spring): [Logs and Metrics Enable Flags 10] Warn for legacy Logs property - #5951

Open
adinauer wants to merge 3 commits into
feat/warn-legacy-logs-externalfrom
feat/warn-legacy-logs-spring
Open

feat(spring): [Logs and Metrics Enable Flags 10] Warn for legacy Logs property#5951
adinauer wants to merge 3 commits into
feat/warn-legacy-logs-externalfrom
feat/warn-legacy-logs-spring

Conversation

@adinauer

@adinauer adinauer commented Aug 13, 2026

Copy link
Copy Markdown
Member

PR Stack (Logs and Metrics Enable Flags)


📜 Description

Injects the Spring Environment into SDK initialization for all three Spring Boot variants and detects explicit sentry.logs.enabled configuration. Migration warnings are emitted after Sentry.init, when the diagnostic logger has been initialized.

Both true and false values emit tailored migration warnings. The obsolete property is not restored to SentryProperties and does not affect capture or the new sentry.logging.enable-logs integration control. Absent configuration emits no warning.

💡 Motivation and Context

After removal of the aggregate Logs option, Spring's relaxed binder ignores the old property. Inspecting the complete Spring Environment preserves a useful migration diagnostic across property files, YAML, environment variables, command-line values, and other property sources.

💚 How did you test it?

  • ./gradlew :sentry-spring-boot:test :sentry-spring-boot-jakarta:test :sentry-spring-boot-4:test
  • ./gradlew spotlessApply apiDump
  • Added absent, explicit true, and explicit false tests to all three Spring Boot variants
  • Verified the integration-local Logback Logs opt-in remains disabled

📝 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

Avoid starting the Logs batch worker thread until the first accepted Log item.

#skip-changelog

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

Inspect the Spring Environment before SDK initialization and emit tailored migration warnings for explicit sentry.logs.enabled values without binding or applying the obsolete property.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 8c2f35f

@sentry

sentry Bot commented Aug 13, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 340.88 ms 401.77 ms 60.89 ms
Size 0 B 0 B 0 B

Baseline results on branch: feat/warn-legacy-logs-external

Startup times

Revision Plain With Sentry Diff
623c4e5 312.67 ms 343.90 ms 31.23 ms

App size

Revision Plain With Sentry Diff
623c4e5 0 B 0 B 0 B

Previous results on branch: feat/warn-legacy-logs-spring

Startup times

Revision Plain With Sentry Diff
c2e4325 310.06 ms 363.22 ms 53.16 ms

App size

Revision Plain With Sentry Diff
c2e4325 0 B 0 B 0 B

Emit legacy Logs property diagnostics after Sentry.init so the configured diagnostic logger is available.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer requested a review from 0xadam-brown as a code owner August 13, 2026 13:41
Comment on lines +200 to +201
Boolean.TRUE.equals(environment.getProperty("sentry.logs.enabled", Boolean.class));
if (enableLogs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The application will crash on startup if sentry.logs.enabled is set to a non-boolean value, as the call to environment.getProperty lacks error handling for invalid conversions.
Severity: HIGH

Suggested Fix

Wrap the environment.getProperty("sentry.logs.enabled", Boolean.class) call in a try-catch block to handle ConversionFailedException. Log a warning if the property value is invalid and default to a sensible value (e.g., false) to allow the application to start successfully. This makes the configuration more robust against user error.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
sentry-spring-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java#L200-L201

Potential issue: The code checks for the existence of the `sentry.logs.enabled` property
but does not validate its value before attempting to convert it to a `Boolean`. If a
user provides a non-boolean string (e.g., "enabled" instead of "true"), Spring's
`StringToBooleanConverter` will throw a `ConversionFailedException`. Since this
exception is not caught during the creation of the `sentryHub` bean, it will propagate
up and cause the entire Spring application context to fail to initialize, preventing the
application from starting.

Also affects:

  • sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java:195~196
  • sentry-spring-boot-4/src/main/java/io/sentry/spring/boot4/SentryAutoConfiguration.java:198~199

Did we get this right? 👍 / 👎 to inform future reviews.

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