stalary commented on a change in pull request #3369: ADD kafka-v2 plugin URL: https://github.com/apache/skywalking/pull/3369#discussion_r319341400
########## File path: apm-sniffer/apm-sdk-plugin/kafka-v1-plugin/src/main/java/org/apache/skywalking/apm/plugin/kafka/v1/KafkaProducerInterceptor.java ########## @@ -47,22 +47,18 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr ProducerRecord record = (ProducerRecord)allArguments[0]; String topicName = (String)((EnhancedInstance)record).getSkyWalkingDynamicField(); - + String key = record.key() == null ? null : (String) record.key(); AbstractSpan activeSpan = ContextManager.createExitSpan(OPERATE_NAME_PREFIX + topicName + PRODUCER_OPERATE_NAME_SUFFIX, contextCarrier, (String)objInst.getSkyWalkingDynamicField()); - Tags.MQ_BROKER.set(activeSpan, (String)objInst.getSkyWalkingDynamicField()); + Tags.MQ_BROKER.set(activeSpan, (String) objInst.getSkyWalkingDynamicField()); Tags.MQ_TOPIC.set(activeSpan, topicName); + Tags.MQ_QUEUE.set(activeSpan, key); SpanLayer.asMQ(activeSpan); activeSpan.setComponent(ComponentsDefine.KAFKA_PRODUCER); - CarrierItem next = contextCarrier.items(); - while (next.hasNext()) { - next = next.next(); - record.headers().add(next.getHeadKey(), next.getHeadValue().getBytes()); - } - - EnhancedInstance callbackInstance = (EnhancedInstance)allArguments[1]; - if (callbackInstance != null) { + // kafkaTemplate can lead to ClassCastException + if (allArguments[1] instanceof EnhancedInstance) { Review comment: Ok, I will adjust it later ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services