Repository: pinpoint-apm/pinpoint
Issue: Fix problem that do not set some fields when an exception occurs
Labels: bug
module:plugin

#### related module
Kafka-Plugin

#### description 
If service type has record statistics, destnationId value have to send for to draw servermap. 
But, current ProducerSendInterceptor code do not set destinationId field when exception occurred while send() method invoked.

For this reason, servermap has not drawn when when exception occurred while send() method invoked.


Issue comments:
This issue expect to have resolved via #6508, #6510

Pull request review comments:

Patch that resolved the issue:
diff --git a/plugins/rabbitmq/src/main/java/com/navercorp/pinpoint/plugin/rabbitmq/client/interceptor/ChannelBasicPublishInterceptor.java b/plugins/rabbitmq/src/main/java/com/navercorp/pinpoint/plugin/rabbitmq/client/interceptor/ChannelBasicPublishInterceptor.java
index 78961d8b9fa1..0618de2e382c 100644
--- a/plugins/rabbitmq/src/main/java/com/navercorp/pinpoint/plugin/rabbitmq/client/interceptor/ChannelBasicPublishInterceptor.java
+++ b/plugins/rabbitmq/src/main/java/com/navercorp/pinpoint/plugin/rabbitmq/client/interceptor/ChannelBasicPublishInterceptor.java
@@ -103,27 +103,27 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
 
             SpanEventRecorder recorder = trace.currentSpanEventRecorder();
             recorder.recordApi(descriptor);
-            if (throwable == null) {
-                String endPoint = RabbitMQClientConstants.UNKNOWN;
-                // Producer's endPoint should be the socket address of where the producer is actually connected to.
-                final Connection connection = ((Channel) target).getConnection();
-                if (connection instanceof AMQConnection) {
-                    AMQConnection amqConnection = (AMQConnection) connection;
-                    FrameHandler frameHandler = amqConnection.getFrameHandler();
-                    if (frameHandler instanceof RemoteAddressAccessor) {
-                        endPoint = ((RemoteAddressAccessor) frameHandler)._$PINPOINT$_getRemoteAddress();
-                    }
+
+            String endPoint = RabbitMQClientConstants.UNKNOWN;
+            // Producer's endPoint should be the socket address of where the producer is actually connected to.
+            final Connection connection = ((Channel) target).getConnection();
+            if (connection instanceof AMQConnection) {
+                AMQConnection amqConnection = (AMQConnection) connection;
+                FrameHandler frameHandler = amqConnection.getFrameHandler();
+                if (frameHandler instanceof RemoteAddressAccessor) {
+                    endPoint = ((RemoteAddressAccessor) frameHandler)._$PINPOINT$_getRemoteAddress();
                 }
-                recorder.recordEndPoint(endPoint);
-                // DestinationId is used to render the virtual queue node.
-                // We choose the exchange name as the logical name of the queue node.
-                recorder.recordDestinationId("exchange-" + exchange);
-
-                recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_EXCHANGE_ANNOTATION_KEY, exchange);
-                recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, routingKey);
-            } else {
-                recorder.recordException(throwable);
             }
+            recorder.recordEndPoint(endPoint);
+            // DestinationId is used to render the virtual queue node.
+            // We choose the exchange name as the logical name of the queue node.
+            recorder.recordDestinationId("exchange-" + exchange);
+
+            recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_EXCHANGE_ANNOTATION_KEY, exchange);
+            recorder.recordAttribute(RabbitMQClientConstants.RABBITMQ_ROUTINGKEY_ANNOTATION_KEY, routingKey);
+
+            recorder.recordException(throwable);
+
         } finally {
             trace.traceBlockEnd();
         }
@@ -136,13 +136,13 @@ private boolean validate(Object target, Object[] args) {
         if (args == null || args.length < 6) {
             return false;
         }
-        if (args[0] !=null && !(args[0] instanceof String)) {
+        if (args[0] != null && !(args[0] instanceof String)) {
             return false;
         }
-        if (args[1] !=null && !(args[1] instanceof String)) {
+        if (args[1] != null && !(args[1] instanceof String)) {
             return false;
         }
-        if (args[4] !=null && !(args[4] instanceof AMQP.BasicProperties)) {
+        if (args[4] != null && !(args[4] instanceof AMQP.BasicProperties)) {
             return false;
         }
         return true;


Test patch: