Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show warning if incompatible spring boot version is detected #3233

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Add `enableScopePersistence` option to disable `PersistingScopeObserver` used for ANR reporting which may increase performance overhead. Defaults to `true` ([#3218](https://github.com/getsentry/sentry-java/pull/3218))
- When disabled, the SDK will not enrich ANRv2 events with scope data (e.g. breadcrumbs, user, tags, etc.)
- Show warning if incompatible spring boot version is detected ([#3233](https://github.com/getsentry/sentry-java/pull/3233))
lbloder marked this conversation as resolved.
Show resolved Hide resolved

### Fixes

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.sentry.spring.boot.jakarta;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.context.event.ApplicationContextInitializedEvent;
import org.springframework.context.ApplicationListener;

final class SentrySpringVersionChecker
implements ApplicationListener<ApplicationContextInitializedEvent> {

private static final Log logger = LogFactory.getLog(SentrySpringVersionChecker.class);

@Override
public void onApplicationEvent(ApplicationContextInitializedEvent event) {

if (!SpringBootVersion.getVersion().startsWith("3")) {
logger.warn("############################### WARNING ###############################");
logger.warn("## ##");
logger.warn("## !Incompatible Spring Boot Version detected! ##");
logger.warn("## Please see the sentry docs linked below ##");
logger.warn("## Choose your Spring Boot version and ##");
logger.warn("## install the matching dependency ##");
logger.warn("## ##");
logger.warn("## https://docs.sentry.io/platforms/java/guides/spring-boot/#install ##");
logger.warn("## ##");
logger.warn("#######################################################################");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.springframework.context.ApplicationListener=io.sentry.spring.boot.jakarta.SentrySpringVersionChecker
Copy link
Member

Choose a reason for hiding this comment

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

h does this still work with Spring 3.3.0-M2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tested with 3.3.0-M2 and is working as expected. Seems like this change was only targeting auto-configuration.
Also the current documentation for 3.3.0-M2 mentions spring.factories as the place to register listeners: https://docs.spring.io/spring-boot/docs/3.3.0-M2/reference/htmlsingle/#features.spring-application.application-events-and-listeners.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.sentry.spring.boot;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.context.event.ApplicationContextInitializedEvent;
import org.springframework.context.ApplicationListener;

final class SentrySpringVersionChecker
implements ApplicationListener<ApplicationContextInitializedEvent> {

private static final Log logger = LogFactory.getLog(SentrySpringVersionChecker.class);

@Override
public void onApplicationEvent(ApplicationContextInitializedEvent event) {

if (!SpringBootVersion.getVersion().startsWith("2")) {
logger.warn("############################### WARNING ###############################");
logger.warn("## ##");
logger.warn("## !Incompatible Spring Boot Version detected! ##");
logger.warn("## Please see the sentry docs linked below ##");
logger.warn("## Choose your Spring Boot version and ##");
logger.warn("## install the matching dependency ##");
logger.warn("## ##");
logger.warn("## https://docs.sentry.io/platforms/java/guides/spring-boot/#install ##");
logger.warn("## ##");
logger.warn("#######################################################################");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
io.sentry.spring.boot.SentryAutoConfiguration,\
io.sentry.spring.boot.SentryLogbackAppenderAutoConfiguration,\
io.sentry.spring.boot.SentryWebfluxAutoConfiguration

org.springframework.context.ApplicationListener=io.sentry.spring.boot.SentrySpringVersionChecker
Loading