Skip to content

Commit

Permalink
Disable setting the context classloader for agent threads
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz committed Apr 2, 2024
1 parent 6028f74 commit 22adba1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static void initialize(@Nullable final String agentArguments, final Instr
// server log appender requires buffering log events before the config and reporter are ready.
.withLifecycleListener(ApmServerLogAppender.getInstance().getInitListener())
.build();
//initInstrumentation(tracer, instrumentation, premain);
initInstrumentation(tracer, instrumentation, premain);
tracer.start(premain);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@ private synchronized void startSync() {
return;
}
apmServerClient.start();
/*
reporter.start();
for (LifecycleListener lifecycleListener : lifecycleListeners) {
try {
Expand All @@ -746,7 +745,6 @@ private synchronized void startSync() {
logger.error("Failed to start " + lifecycleListener.getClass().getName(), e);
}
}
*/
tracerState = TracerState.RUNNING;
if (recordingConfigOptionSet) {
logger.info("Tracer switched to RUNNING state");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public void onChange(ConfigurationOption<?> configurationOption, List<URL> oldVa
setServerUrls(reporterConfiguration.getServerUrls());
}
});
// TODO: why does this prevent duplicate logging?
// setServerUrls(Collections.unmodifiableList(shuffledUrls));
setServerUrls(Collections.unmodifiableList(shuffledUrls));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Thread newThread(Runnable r) {
String threadName = ThreadUtils.addElasticApmThreadPrefix(threadPurpose);
thread.setName(threadName);
ClassLoader originalContextCL = PrivilegedActionUtils.getContextClassLoader(thread);
PrivilegedActionUtils.setContextClassLoader(thread, PrivilegedActionUtils.getClassLoader(ExecutorUtils.class));
//PrivilegedActionUtils.setContextClassLoader(thread, PrivilegedActionUtils.getClassLoader(ExecutorUtils.class));
logThreadCreation(originalContextCL, threadName);
return thread;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public Thread newThread(Runnable r) {
String threadName = ThreadUtils.addElasticApmThreadPrefix(threadPurpose) + "-" + threadCounter.getAndIncrement();
thread.setName(threadName);
ClassLoader originalContextCL = PrivilegedActionUtils.getContextClassLoader(thread);
PrivilegedActionUtils.setContextClassLoader(thread, PrivilegedActionUtils.getClassLoader(ExecutorUtils.class));
//PrivilegedActionUtils.setContextClassLoader(thread, PrivilegedActionUtils.getClassLoader(ExecutorUtils.class));
logThreadCreation(originalContextCL, threadName);
return thread;
}
Expand Down

0 comments on commit 22adba1

Please sign in to comment.