@@ -616,5 +616,41 @@ private void sendPushNotification(String taskId, ResultAggregator resultAggregat
616616 }
617617 }
618618
619+ /**
620+ * Log current thread and resource statistics for debugging.
621+ * Call this from debugger or add strategic calls during investigation.
622+ */
623+ @ SuppressWarnings ("unused" ) // Used for debugging
624+ private void logThreadStats (String label ) {
625+ ThreadGroup rootGroup = Thread .currentThread ().getThreadGroup ();
626+ while (rootGroup .getParent () != null ) {
627+ rootGroup = rootGroup .getParent ();
628+ }
629+ int activeThreads = rootGroup .activeCount ();
630+
631+ LOGGER .info ("=== THREAD STATS: {} ===" , label );
632+ LOGGER .info ("Active threads: {}" , activeThreads );
633+ LOGGER .info ("Running agents: {}" , runningAgents .size ());
634+ LOGGER .info ("Background tasks: {}" , backgroundTasks .size ());
635+ LOGGER .info ("Queue manager active queues: {}" , queueManager .getClass ().getSimpleName ());
636+
637+ // List running agents
638+ if (!runningAgents .isEmpty ()) {
639+ LOGGER .info ("Running agent tasks:" );
640+ runningAgents .forEach ((taskId , future ) ->
641+ LOGGER .info (" - Task {}: {}" , taskId , future .isDone () ? "DONE" : "RUNNING" )
642+ );
643+ }
644+
645+ // List background tasks
646+ if (!backgroundTasks .isEmpty ()) {
647+ LOGGER .info ("Background tasks:" );
648+ backgroundTasks .forEach (task ->
649+ LOGGER .info (" - {}: {}" , task , task .isDone () ? "DONE" : "RUNNING" )
650+ );
651+ }
652+ LOGGER .info ("=== END THREAD STATS ===" );
653+ }
654+
619655 private record MessageSendSetup (TaskManager taskManager , Task task , RequestContext requestContext ) {}
620656}
0 commit comments