Skip to content

Commit

Permalink
Only call shutdownLogsIntake at shutdown if we previously called mayb…
Browse files Browse the repository at this point in the history
…eStartLogsIntake at startup.

This avoids a ClassNotFoundException when shutting down native images - the native-image won't
contain the LogsIntakeSystem class because it wasn't started when the native-image was built,
therefore we should avoid trying to shut it down unconditionally.
  • Loading branch information
mcculls committed Jun 16, 2024
1 parent ecd93fb commit 4551c9b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public boolean isEnabledByDefault() {
private static boolean usmEnabled = false;
private static boolean telemetryEnabled = true;
private static boolean debuggerEnabled = false;
private static boolean logsIntakeStarted = false;

public static void start(final Instrumentation inst, final URL agentJarURL, String agentArgs) {
StaticEventLogger.begin("Agent");
Expand Down Expand Up @@ -362,7 +363,9 @@ public static void shutdown(final boolean sync) {
if (telemetryEnabled) {
stopTelemetry();
}
shutdownLogsIntake();
if (logsIntakeStarted) {
shutdownLogsIntake();
}
}

public static synchronized Class<?> installAgentCLI() throws Exception {
Expand Down Expand Up @@ -808,6 +811,7 @@ private static void maybeStartLogsIntake(Class<?> scoClass, Object sco) {
AGENT_CLASSLOADER.loadClass("datadog.trace.logging.intake.LogsIntakeSystem");
final Method logsIntakeInstallerMethod = logsIntakeSystemClass.getMethod("start", scoClass);
logsIntakeInstallerMethod.invoke(null, sco);
logsIntakeStarted = true;
} catch (final Throwable e) {
log.warn("Not starting Logs Intake subsystem", e);
}
Expand Down

0 comments on commit 4551c9b

Please sign in to comment.