-
Notifications
You must be signed in to change notification settings - Fork 150
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
include debug as env #890
Merged
Merged
include debug as env #890
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,12 +223,12 @@ public static String getAgentJarAttribute(String name) { | |
} | ||
} | ||
|
||
// The "newrelic.debug" flag redirects all Agent logging to the standard output. Unfortunately, | ||
// The "newrelic.debug" flag redirects all Agent logging (prior to log init) to the standard output -after log init, log as usual. Unfortunately, | ||
// we haven't initialized the Agent yet, so we cannot check it in the usual low-cost way by | ||
// calling Agent.isDebugEnabled(). So we duplicate the functionality here for use in a few cases. | ||
private static final boolean isNewRelicDebug() { | ||
final String newrelicDebug = "newrelic.debug"; | ||
return System.getProperty(newrelicDebug) != null && Boolean.getBoolean(newrelicDebug); | ||
return Boolean.getBoolean(newrelicDebug) || Boolean.parseBoolean(System.getenv("NEWRELIC_DEBUG")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Boolean.getBoolean already provides a null guard and defaults to false. removed unnecessary null guard. |
||
} | ||
|
||
// Use of this method should be limited to serious error cases that would cause the Agent to | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This could be a static initialization block. Or a public static method, that can be used in the other parts of the code that are making the same verification.
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.
@meiao Are you thinking to include the other static members in the block or just for DEBUG?
Or just:
isDebugEnabled()
is public so other places can already check. Do we want other places to be able to set? It was actually a final variable, so should only set once...unless you think change that?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 just added setDebug as a private member because I thought it might look cleaner to move the boolean checks out of that section since there are multiple checks.
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.
My first idea was to drop the method.
But as I read thru the PR, there are 3 other places that make the same logic:
So instead of copying that all the time, it could be a method that all call.
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 see. One of the problems with one of the places is that Agent class hasn't been initialized when it is called. It was unclear to me why the original author didn't decide to make static call from AgentJarHelper where they had to duplicate it.
newrelic-java-agent/newrelic-agent/src/main/java/com/newrelic/agent/config/AgentJarHelper.java
Line 227 in 0638d86
Do you think leave AgentJarHelper as is and just the Agent class in the other places where we can? Or something else?
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.
OH, using it in AgentJarHelper would initialize it wouldn't it.