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

Don't require sentry.dsn to be set when using spring-boot-starter and logback together #965

Merged
merged 4 commits into from
Oct 6, 2020

Conversation

buckett
Copy link
Contributor

@buckett buckett commented Oct 5, 2020

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This only configures the logback appender when sentry is configured by making the sentry properties a dependency on the appender auto configuration being applied.

💡 Motivation and Context

Make the configuration simpler when you don't want to use sentry (eg on developers machines)

💚 How did you test it?

  • Built project locally and deployed to local maven repository and upgraded local project to 3.0.1-SNAPSHOT.
  • Started up local project without sentry.dsn but with the sentry dependencies and checked it started.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

buckett and others added 2 commits October 5, 2020 20:09
This means if you don't set sentry.dsn you can still have the files on the classpath.
This only configures the logbook appender when sentry is configured by making the sentry properties a dependency on the appender auto configuration being applied.

Fixes getsentry#964
@bruno-garcia
Copy link
Member

Could you please add an entry to the changelog?

@buckett
Copy link
Contributor Author

buckett commented Oct 5, 2020

This should fix #964

Copy link
Contributor

@maciejwalkowiak maciejwalkowiak left a comment

Choose a reason for hiding this comment

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

Thanks for finding, reporting and fixing the bug! I think we can improve the tests a little.

contextRunner
.run {
assertThat(it).doesNotHaveBean(IHub::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make more sense to verify if the appender is configured?

assertThat(rootLogger.getAppenders(SentryAppender::class.java)).isEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I'm sure it does :-) Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fantastic, thank you!

@@ -29,16 +29,24 @@ class SentryLogbackAppenderAutoConfigurationTest {
}

@Test
fun `configures SentryAppender`() {
fun `hub is not created when auto-configuration dsn is not set`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this test should verify that "does not configure SentryAppender when auto-configuration dsn is not set".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved, thanks.

Copy link
Contributor

@maciejwalkowiak maciejwalkowiak left a comment

Choose a reason for hiding this comment

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

Thanks again for your contribution!

@bruno-garcia bruno-garcia merged commit e874a54 into getsentry:main Oct 6, 2020
@bruno-garcia
Copy link
Member

Thanks @buckett @maciejwalkowiak

@bruno-garcia bruno-garcia changed the title Fix 964 Don't require sentry.dsn to be set when using io.sentry:sentry-spring-boot-starter and io.sentry:sentry-logback together Oct 6, 2020
@bruno-garcia bruno-garcia changed the title Don't require sentry.dsn to be set when using io.sentry:sentry-spring-boot-starter and io.sentry:sentry-logback together Don't require sentry.dsn to be set when using spring-boot-starter and logback together Oct 6, 2020
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.

3 participants