Repository: pinpoint-apm/pinpoint
Issue: Jedis get `Unknown` endpoint when using `spring-boot-starter-data-redis`
Labels: bug
module:plugin

#### contribution info
* Contributor : @hoverwinter 


- spring-boot 2.4.2 (spring-boot-starter-data-redis) with default configuration.

Reason:

`JedisPlugin` has no interceptor for following constructor of `BinaryJedis`:

- public BinaryJedis(String host, int port, int connectionTimeout, int soTimeout, int infiniteSoTimeout)
- public BinaryJedis(String host, int port, int connectionTimeout, int soTimeout, int infiniteSoTimeout, boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
- public BinaryJedis(URI uri, int connectionTimeout, int soTimeout, int infiniteSoTimeout, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier)
- public BinaryJedis(final JedisSocketFactory jedisSocketFactory)

New parameter named `infiniteSoTimeout` is introduced in new version, such as `3.4.0`

Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/plugins/bom/pom.xml b/plugins/bom/pom.xml
index 02637114fffc..f032d39c78c3 100644
--- a/plugins/bom/pom.xml
+++ b/plugins/bom/pom.xml
@@ -30,7 +30,7 @@
     <name>pinpoint-plugin-bom</name>
 
     <properties>
-        <jedis.version>2.4.2</jedis.version>
+        <jedis.version>3.4.0</jedis.version>
         <lettuce.version>5.1.2.RELEASE</lettuce.version>
         <cassandra.driver.version>2.1.7.1</cassandra.driver.version>
         <dubbo.version>2.5.3</dubbo.version>
diff --git a/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/JedisPlugin.java b/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/JedisPlugin.java
index 8e0996a7ec49..abe3b67f08b7 100644
--- a/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/JedisPlugin.java
+++ b/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/JedisPlugin.java
@@ -113,10 +113,14 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader,
             JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "boolean", "javax.net.ssl.SSLSocketFactory", "javax.net.ssl.SSLParameters", "javax.net.ssl.HostnameVerifier");
             // host, port, connectionTimeout, soTimeout
             JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "int");
+            // host, port, connectionTimeout, soTimeout, infiniteSoTimeout
+            JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "int", "int");
             // host, port, connectionTimeout, soTimeout, ssl
             JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "int", "boolean");
             // host, port, connectionTimeout, soTimeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier
             JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "int", "boolean", "javax.net.ssl.SSLSocketFactory", "javax.net.ssl.SSLParameters", "javax.net.ssl.HostnameVerifier");
+            // host, port, connectionTimeout, soTimeout, infiniteSoTimeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier
+            JedisUtils.addSetEndPointInterceptor(target, "java.lang.String", "int", "int", "int", "int", "boolean", "javax.net.ssl.SSLSocketFactory", "javax.net.ssl.SSLParameters", "javax.net.ssl.HostnameVerifier");
             // shardInfo
             JedisUtils.addSetEndPointInterceptor(target, "redis.clients.jedis.JedisShardInfo");
             // uri
@@ -131,6 +135,10 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader,
             JedisUtils.addSetEndPointInterceptor(target, "java.net.URI", "int", "int");
             // uri, connectionTimeout, soTimeout, sslSocketFactory, sslParameters, hostnameVerifier
             JedisUtils.addSetEndPointInterceptor(target, "java.net.URI", "int", "int", "javax.net.ssl.SSLSocketFactory", "javax.net.ssl.SSLParameters", "javax.net.ssl.HostnameVerifier");
+            // uri, connectionTimeout, soTimeout, infiniteSoTimeout, sslSocketFactory, sslParameters, hostnameVerifier
+            JedisUtils.addSetEndPointInterceptor(target, "java.net.URI", "int", "int", "int", "javax.net.ssl.SSLSocketFactory", "javax.net.ssl.SSLParameters", "javax.net.ssl.HostnameVerifier");
+            // redis.clients.jedis.JedisSocketFactory
+            JedisUtils.addSetEndPointInterceptor(target, "redis.clients.jedis.JedisSocketFactory");
 
             // methods(commands)
             final JedisPluginConfig config = new JedisPluginConfig(instrumentor.getProfilerConfig());
diff --git a/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/interceptor/SetEndPointInterceptor.java b/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/interceptor/SetEndPointInterceptor.java
index 505fffe64d37..a16fdca3f371 100644
--- a/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/interceptor/SetEndPointInterceptor.java
+++ b/plugins/redis/src/main/java/com/navercorp/pinpoint/plugin/redis/jedis/interceptor/SetEndPointInterceptor.java
@@ -29,6 +29,7 @@
 import com.navercorp.pinpoint.bootstrap.logging.PLogger;
 import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
 import com.navercorp.pinpoint.plugin.redis.jedis.EndPointAccessor;
+import redis.clients.jedis.JedisSocketFactory;
 
 /**
  * Jedis (redis client) constructor interceptor
@@ -75,6 +76,9 @@ private String getEndPoint(Object[] args) {
         } else if (argZero instanceof JedisShardInfo) {
             final JedisShardInfo info = (JedisShardInfo) argZero;
             return HostAndPort.toHostAndPortString(info.getHost(), info.getPort());
+        } else if (argZero instanceof JedisSocketFactory) {
+            final JedisSocketFactory factory = (JedisSocketFactory) argZero;
+            return HostAndPort.toHostAndPortString(factory.getHost(), factory.getPort());
         }
         return "Unknown";
     }


Test patch: