Skip to content

Commit 4f0931c

Browse files
committed
Debug code
1 parent c14d6b8 commit 4f0931c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

server-common/src/main/java/io/a2a/server/requesthandlers/DefaultRequestHandler.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)