Repository: pinpoint-apm/pinpoint
Issue: Allows the ClientOption setting in the setup file
Labels: enhancement
module:project-common

#### description
Currently, ClientOption settings are forced to be programmatically. 
Will change to allows the ClientOption setting in the setup file.
Then, User can customize it for user's environment. 


Issue comments:
closed via #4349

Pull request review comments:

Patch that resolved the issue:
diff --git a/agent/src/main/resources-local/pinpoint.config b/agent/src/main/resources-local/pinpoint.config
index 78ed42eeeb3f..8b1fcbe4f227 100644
--- a/agent/src/main/resources-local/pinpoint.config
+++ b/agent/src/main/resources-local/pinpoint.config
@@ -90,6 +90,12 @@ profiler.tcpdatasender.command.activethread.count.enable=true
 profiler.tcpdatasender.command.activethread.threaddump.enable=true
 profiler.tcpdatasender.command.activethread.threadlightdump.enable=true
 
+profiler.tcpdatasender.client.write.timeout=3000
+profiler.tcpdatasender.client.request.timeout=3000
+profiler.tcpdatasender.client.reconnect.interval=3000
+profiler.tcpdatasender.client.ping.interval=300000
+profiler.tcpdatasender.client.handshake.interval=60000
+
 # Trace Agent active thread info.
 profiler.pinpoint.activethread=true
 
diff --git a/agent/src/main/resources-release/pinpoint.config b/agent/src/main/resources-release/pinpoint.config
index 308aa99a5e04..2ae0975d3ed7 100644
--- a/agent/src/main/resources-release/pinpoint.config
+++ b/agent/src/main/resources-release/pinpoint.config
@@ -86,6 +86,12 @@ profiler.tcpdatasender.command.activethread.count.enable=true
 profiler.tcpdatasender.command.activethread.threaddump.enable=true
 profiler.tcpdatasender.command.activethread.threadlightdump.enable=true
 
+profiler.tcpdatasender.client.write.timeout=3000
+profiler.tcpdatasender.client.request.timeout=3000
+profiler.tcpdatasender.client.reconnect.interval=3000
+profiler.tcpdatasender.client.ping.interval=300000
+profiler.tcpdatasender.client.handshake.interval=60000
+
 # Trace Agent active thread info.
 profiler.pinpoint.activethread=true
 
diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java
index ff6a15922dc2..ed2029da3db5 100644
--- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java
+++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java
@@ -131,6 +131,17 @@ public static ProfilerConfig load(String pinpointConfigFileName) throws IOExcept
     private boolean tcpDataSenderCommandActiveThreadDumpEnable = false;
     private boolean tcpDataSenderCommandActiveThreadLightDumpEnable = false;
 
+    private static long DEFAULT_DATA_SENDER_PINPOINT_CLIENT_WRITE_TIMEOUT = 3 * 1000;
+    private long tcpDataSenderPinpointClientWriteTimeout = DEFAULT_DATA_SENDER_PINPOINT_CLIENT_WRITE_TIMEOUT;
+    private static long DEFAULT_DATA_SENDER_PINPOINT_CLIENT_REQUEST_TIMEOUT = 3 * 1000;
+    private long tcpDataSenderPinpointClientRequestTimeout = DEFAULT_DATA_SENDER_PINPOINT_CLIENT_REQUEST_TIMEOUT;
+    private static long DEFAULT_DATA_SENDER_PINPOINT_CLIENT_RECONNECT_INTERVAL = 3 * 1000;
+    private long tcpDataSenderPinpointClientReconnectInterval = DEFAULT_DATA_SENDER_PINPOINT_CLIENT_RECONNECT_INTERVAL;
+    private static long DEFAULT_DATA_SENDER_PINPOINT_CLIENT_PING_INTERVAL = 60 * 1000 * 5;
+    private long tcpDataSenderPinpointClientPingInterval = DEFAULT_DATA_SENDER_PINPOINT_CLIENT_PING_INTERVAL;
+    private static long DEFAULT_DATA_SENDER_PINPOINT_CLIENT_HANDSHAKE_INTERVAL = 60 * 1000 * 1;
+    private long tcpDataSenderPinpointClientHandshakeInterval = DEFAULT_DATA_SENDER_PINPOINT_CLIENT_HANDSHAKE_INTERVAL;
+
     private boolean traceAgentActiveThread = true;
 
     private boolean traceAgentDataSource = false;
@@ -285,6 +296,31 @@ public boolean isTcpDataSenderCommandActiveThreadLightDumpEnable() {
         return tcpDataSenderCommandActiveThreadLightDumpEnable;
     }
 
+    @Override
+    public long getTcpDataSenderPinpointClientWriteTimeout() {
+        return tcpDataSenderPinpointClientWriteTimeout;
+    }
+
+    @Override
+    public long getTcpDataSenderPinpointClientRequestTimeout() {
+        return tcpDataSenderPinpointClientRequestTimeout;
+    }
+
+    @Override
+    public long getTcpDataSenderPinpointClientReconnectInterval() {
+        return tcpDataSenderPinpointClientReconnectInterval;
+    }
+
+    @Override
+    public long getTcpDataSenderPinpointClientPingInterval() {
+        return tcpDataSenderPinpointClientPingInterval;
+    }
+
+    @Override
+    public long getTcpDataSenderPinpointClientHandshakeInterval() {
+        return tcpDataSenderPinpointClientHandshakeInterval;
+    }
+
     @Override
     public boolean isTraceAgentActiveThread() {
         return traceAgentActiveThread;
@@ -541,6 +577,12 @@ void readPropertyValues() {
         this.tcpDataSenderCommandActiveThreadDumpEnable = readBoolean("profiler.tcpdatasender.command.activethread.threaddump.enable", false);
         this.tcpDataSenderCommandActiveThreadLightDumpEnable = readBoolean("profiler.tcpdatasender.command.activethread.threadlightdump.enable", false);
 
+        this.tcpDataSenderPinpointClientWriteTimeout = readLong("profiler.tcpdatasender.client.write.timeout", DEFAULT_DATA_SENDER_PINPOINT_CLIENT_WRITE_TIMEOUT);
+        this.tcpDataSenderPinpointClientRequestTimeout = readLong("profiler.tcpdatasender.client.request.timeout", DEFAULT_DATA_SENDER_PINPOINT_CLIENT_REQUEST_TIMEOUT);
+        this.tcpDataSenderPinpointClientReconnectInterval = readLong("profiler.tcpdatasender.client.reconnect.interval", DEFAULT_DATA_SENDER_PINPOINT_CLIENT_RECONNECT_INTERVAL);
+        this.tcpDataSenderPinpointClientPingInterval = readLong("profiler.tcpdatasender.client.ping.interval", DEFAULT_DATA_SENDER_PINPOINT_CLIENT_PING_INTERVAL);
+        this.tcpDataSenderPinpointClientHandshakeInterval = readLong("profiler.tcpdatasender.client.handshake.interval", DEFAULT_DATA_SENDER_PINPOINT_CLIENT_HANDSHAKE_INTERVAL);
+
         this.traceAgentActiveThread = readBoolean("profiler.pinpoint.activethread", true);
 
         this.traceAgentDataSource = readBoolean("profiler.pinpoint.datasource", false);
@@ -742,6 +784,11 @@ public String toString() {
         sb.append(", tcpDataSenderCommandActiveThreadCountEnable=").append(tcpDataSenderCommandActiveThreadCountEnable);
         sb.append(", tcpDataSenderCommandActiveThreadDumpEnable=").append(tcpDataSenderCommandActiveThreadDumpEnable);
         sb.append(", tcpDataSenderCommandActiveThreadLightDumpEnable=").append(tcpDataSenderCommandActiveThreadLightDumpEnable);
+        sb.append(", tcpDataSenderPinpointClientWriteTimeout=").append(tcpDataSenderPinpointClientWriteTimeout);
+        sb.append(", tcpDataSenderPinpointClientRequestTimeout=").append(tcpDataSenderPinpointClientRequestTimeout);
+        sb.append(", tcpDataSenderPinpointClientReconnectInterval=").append(tcpDataSenderPinpointClientReconnectInterval);
+        sb.append(", tcpDataSenderPinpointClientPingInterval=").append(tcpDataSenderPinpointClientPingInterval);
+        sb.append(", tcpDataSenderPinpointClientHandshakeInterval=").append(tcpDataSenderPinpointClientHandshakeInterval);
         sb.append(", traceAgentActiveThread=").append(traceAgentActiveThread);
         sb.append(", traceAgentDataSource=").append(traceAgentDataSource);
         sb.append(", dataSourceTraceLimitSize=").append(dataSourceTraceLimitSize);
@@ -775,4 +822,5 @@ public String toString() {
         sb.append('}');
         return sb.toString();
     }
+
 }
\ No newline at end of file
diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java
index 6f370c246e1a..e990dc946393 100644
--- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java
+++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java
@@ -65,6 +65,16 @@ public interface ProfilerConfig {
 
     boolean isTcpDataSenderCommandActiveThreadLightDumpEnable();
 
+    long getTcpDataSenderPinpointClientWriteTimeout();
+
+    long getTcpDataSenderPinpointClientRequestTimeout();
+
+    long getTcpDataSenderPinpointClientReconnectInterval();
+
+    long getTcpDataSenderPinpointClientPingInterval();
+
+    long getTcpDataSenderPinpointClientHandshakeInterval();
+
     boolean isTraceAgentActiveThread();
 
     boolean isTraceAgentDataSource();
diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/PinpointClientFactoryProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/PinpointClientFactoryProvider.java
index 81c77c43dde5..6d423254bfb4 100644
--- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/PinpointClientFactoryProvider.java
+++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/PinpointClientFactoryProvider.java
@@ -61,8 +61,11 @@ public PinpointClientFactoryProvider(ProfilerConfig profilerConfig, Provider<Age
 
     public PinpointClientFactory get() {
         PinpointClientFactory pinpointClientFactory = new DefaultPinpointClientFactory(connectionFactoryProvider.get());
-        pinpointClientFactory.setWriteTimeoutMillis(1000 * 3);
-        pinpointClientFactory.setRequestTimeoutMillis(1000 * 5);
+        pinpointClientFactory.setWriteTimeoutMillis(profilerConfig.getTcpDataSenderPinpointClientWriteTimeout());
+        pinpointClientFactory.setRequestTimeoutMillis(profilerConfig.getTcpDataSenderPinpointClientRequestTimeout());
+        pinpointClientFactory.setReconnectDelay(profilerConfig.getTcpDataSenderPinpointClientReconnectInterval());
+        pinpointClientFactory.setPingDelay(profilerConfig.getTcpDataSenderPinpointClientPingInterval());
+        pinpointClientFactory.setEnableWorkerPacketDelay(profilerConfig.getTcpDataSenderPinpointClientHandshakeInterval());
 
         AgentInformation agentInformation = this.agentInformation.get();
         Map<String, Object> properties = toMap(agentInformation);


Test patch: