Skip to content

Commit ec821c1

Browse files
authored
Make the warning in ScriptInitializer less scary (#7514)
1 parent bb9b598 commit ec821c1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

dd-java-agent/agent-crashtracking/src/main/java/com/datadog/crashtracking/ScriptInitializer.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ private static void initializeCrashUploader(HotSpotDiagnosticMXBean diagBean) {
131131
String onErrorFile = diagBean.getVMOption("ErrorFile").getValue();
132132
CrashUploaderScriptInitializer.initialize(onErrorVal, onErrorFile);
133133
} catch (Throwable t) {
134-
LOG.warn(
135-
"Failed creating custom crash upload script. Crash tracking will not work properly.", t);
134+
logInitializationError(
135+
"Unexpected exception while creating custom crash upload script. Crash tracking will not work properly.",
136+
t);
136137
}
137138
}
138139

@@ -141,7 +142,19 @@ private static void initializeOOMENotifier(HotSpotDiagnosticMXBean diagBean) {
141142
String onOutOfMemoryVal = diagBean.getVMOption("OnOutOfMemoryError").getValue();
142143
OOMENotifierScriptInitializer.initialize(onOutOfMemoryVal);
143144
} catch (Throwable t) {
144-
LOG.warn("Failed initializing OOME notifier. OOMEs will not be tracked.", t);
145+
logInitializationError(
146+
"Unexpected exception while initializing OOME notifier. OOMEs will not be tracked.", t);
147+
}
148+
}
149+
150+
private static void logInitializationError(String msg, Throwable t) {
151+
if (LOG.isDebugEnabled()) {
152+
LOG.warn("{}", msg, t);
153+
} else {
154+
LOG.warn(
155+
"{} [{}] (Change the logging level to debug to see the full stacktrace)",
156+
msg,
157+
t.getMessage());
145158
}
146159
}
147160
}

0 commit comments

Comments
 (0)