From 0e88cd171dc73b9548492ad10663e4bc88c7d2cd Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Mon, 29 Apr 2024 15:50:00 -0400 Subject: [PATCH] fix: Log HttpJson's async thread pool core size --- .../google/api/gax/core/InstantiatingExecutorProvider.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java b/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java index 1faee91a4a..25c8213f02 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/core/InstantiatingExecutorProvider.java @@ -34,6 +34,8 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.logging.Logger; /** * InstantiatingChannelProvider is an ExecutorProvider which constructs a new @@ -41,6 +43,9 @@ */ @AutoValue public abstract class InstantiatingExecutorProvider implements ExecutorProvider { + private static final Logger LOGGER = + Logger.getLogger(InstantiatingExecutorProvider.class.getName()); + // Thread factory to use to create our worker threads private static final ThreadFactory DEFAULT_THREAD_FACTORY = new ThreadFactory() { @@ -95,6 +100,8 @@ public static Builder newBuilder() { public static Builder newIOBuilder() { int numCpus = Runtime.getRuntime().availableProcessors(); int numThreads = IO_THREAD_MULTIPLIER * Math.max(MIN_THREAD_AMOUNT, numCpus); + LOGGER.log( + Level.CONFIG, String.format("Thread Pool for requests has Core Pool Size: %d", numThreads)); return new AutoValue_InstantiatingExecutorProvider.Builder() .setExecutorThreadCount(numThreads)