Merge pull request #681 from DataDog/tyler/customlog-logging

Add logging to JMXFetch initialization delay
This commit is contained in:
Tyler Benson 2019-01-30 11:49:24 -08:00 committed by GitHub
commit dbbc804fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -46,6 +46,7 @@ public class TracingAgent {
throws Exception {
startDatadogAgent(agentArgs, inst);
if (isAppUsingCustomLogManager()) {
System.out.println("Custom logger found. Delaying JMXFetch initialization.");
/*
* java.util.logging.LogManager maintains a final static LogManager, which is created during class initialization.
*
@ -67,7 +68,7 @@ public class TracingAgent {
public void run() {
try {
startJmxFetch();
} catch (Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -111,6 +112,7 @@ public class TracingAgent {
}
public static synchronized void startJmxFetch() throws Exception {
System.out.println("Starting JMXFetch.");
initializeJars();
if (JMXFETCH_CLASSLOADER == null) {
final ClassLoader jmxFetchClassLoader = createDatadogClassLoader(bootstrapJar, jmxFetchJar);
@ -243,6 +245,19 @@ public class TracingAgent {
*/
private static boolean isAppUsingCustomLogManager() {
final String tracerCustomLogManSysprop = "dd.app.customlogmanager";
if ("debug"
.equalsIgnoreCase(System.getProperty("datadog.slf4j.simpleLogger.defaultLogLevel"))) {
System.out.println(
"Prop - logging.manager: " + System.getProperty("java.util.logging.manager"));
System.out.println(
"Prop - customlogmanager: " + System.getProperty(tracerCustomLogManSysprop));
System.out.println(
"Env - customlogmanager: "
+ System.getenv(tracerCustomLogManSysprop.replace('.', '_').toUpperCase()));
System.out.println(
"Classpath - jboss: " + ClassLoader.getSystemResource("org/jboss/modules/Main.class")
!= null);
}
return System.getProperty("java.util.logging.manager") != null
|| Boolean.parseBoolean(System.getProperty(tracerCustomLogManSysprop))
|| Boolean.parseBoolean(