-
-
Notifications
You must be signed in to change notification settings - Fork 435
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
Conversation
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>
sentry-samples/sentry-samples-logback/src/main/resources/logback.xml
Outdated
Show resolved
Hide resolved
@@ -305,4 +306,11 @@ class SentryAppenderTest { | |||
}, anyOrNull()) | |||
} | |||
} | |||
|
|||
@Test | |||
fun `does not initialize Sentry when DSN is null`() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
…java Co-authored-by: Manoel Aranda Neto <[email protected]>
📜 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:
With this change:
💚 How did you test it?
📝 Checklist