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

Simplify configuring Logback integration when environment variable with the DSN is not set. #1271

Merged
merged 6 commits into from
Feb 22, 2021

Conversation

maciejwalkowiak
Copy link
Contributor

@maciejwalkowiak maciejwalkowiak commented Feb 18, 2021

📜 Description

Simplify configuring Logback integration when environment variable with the DSN is not set.

💡 Motivation and Context

When an environment property that is referenced in logback.xml is not set, Logback sets its value to PROPERTY_NAME_IS_UNDEFINED (not a null like it could have been expected). This complicates setting up SentryLogback appender configuration where the integration should be disabled in environments that do not have this property.

Before this change, users had to do:

<options>
  <dsn>${PROPERTY:- }</dsn>
</options>

With this change:

<options>
  <dsn>${PROPERTY}</dsn>
</options>

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

When an environment property that is referenced in logback.xml is not set, Logback sets its value to PROPERTY_NAME_IS_UNDEFINED (not a `null` like it could have been expected). This complicates setting up SentryLogback appender configuration where the integration should be disabled in environments that do not have this property.

Before this change, users had to do:

<options>
  <dsn>${PROPERTY:- }
</options>

With this change:

<options>
  <dsn>${PROPERTY}
</options>
@@ -305,4 +306,11 @@ class SentryAppenderTest {
}, anyOrNull())
}
}

@Test
fun `does not initialize Sentry when DSN is null`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

on Android or standard Sentry.init, if no DSN is passed (null), we throw an exception, because "" empty DSN means disabled SDK, are we allowing to do differently on logback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed the test name, as we are not really handling null here. Logback has this weird behavior, that when the env is not set it gets a value "ENV_NAME_IS_UNDEFINED" and the only way to handle it properly is to write it like ${PROPERTY:- }.

We can either clarify it in the docs or make it easier for users. This has been roughly discussed with @bruno-garcia - would be nice if he also has a quick look

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

left a suggestion, otherwise LGTM

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