I am trying to determine what's causing the slowdown on my app when I put it on load. Putting in .log is still hard to find where things are getting impacted. So I was thinking of somehow putting it in the Scheduler or at least wrapping it somehow so that I can log if the thread has detected it is taking a long time. However, I am not really sure how to get about it at the moment. If I create a ThreadFactory wrapper I am not sure how to inject it in as ReactorThreadFactory is not exposed.
@Slf4j
@RequiredArgsConstructor
public class LoggingThreadFactory implements ThreadFactory {
private final ThreadFactory delegate;
@Override
public Thread newThread(Runnable r) {
return delegate.newThread(new LoggingRunnable(r));
}
@RequiredArgsConstructor
static class LoggingRunnable implements Runnable {
private final Runnable runnableDelegate;
@Override
public void run() {
final long start = System.currentTimeMillis();
try {
runnableDelegate.run();
} finally {
final var time = System.currentTimeMillis() - start;
if (time > 1000) {
log.error("{} took {} ms", runnableDelegate, time);
}
}
}
}
}
There's also a setExecutorServiceDecorator but I am not sure how to use that.