You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/04/26 08:50:26 UTC

[GitHub] [skywalking] divyakumarjain commented on a change in pull request #6837: Fix #6835 Add compatibility with Kafka client version 2.8.x

divyakumarjain commented on a change in pull request #6837:
URL: https://github.com/apache/skywalking/pull/6837#discussion_r620097467



##########
File path: apm-sniffer/apm-sdk-plugin/kafka-plugin/src/main/java/org/apache/skywalking/apm/plugin/kafka/ConsumerConstructorInterceptor.java
##########
@@ -22,18 +22,49 @@
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
- *
+ * @author zhang xin, stalary
  **/
 public class ConsumerConstructorInterceptor implements InstanceConstructorInterceptor {
 
-    @Override
-    public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
-        ConsumerConfig config = (ConsumerConfig) allArguments[0];
-        // set the bootstrap server address
-        ConsumerEnhanceRequiredInfo requiredInfo = new ConsumerEnhanceRequiredInfo();
-        requiredInfo.setBrokerServers(config.getList("bootstrap.servers"));
-        requiredInfo.setGroupId(config.getString("group.id"));
+    @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+        ConsumerEnhanceRequiredInfo requiredInfo = resolveConsumerEnhanceRequiredInfo( allArguments[0] );
         objInst.setSkyWalkingDynamicField(requiredInfo);
     }
+
+    private ConsumerEnhanceRequiredInfo resolveConsumerEnhanceRequiredInfo( Object configArgument )
+    {
+        ConsumerEnhanceRequiredInfo requiredInfo = new ConsumerEnhanceRequiredInfo();
+
+        if(configArgument instanceof ConsumerConfig) {
+            ConsumerConfig config = (ConsumerConfig) configArgument;
+            // set the bootstrap server address
+            requiredInfo.setBrokerServers(config.getList("bootstrap.servers"));
+            requiredInfo.setGroupId(config.getString("group.id"));
+        } else if (configArgument instanceof Map ) {

Review comment:
       Will create new Interceptor.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org