codelipenghui commented on a change in pull request #6774:
URL: https://github.com/apache/skywalking/pull/6774#discussion_r617186558



##########
File path: 
apm-sniffer/apm-sdk-plugin/pulsar-plugin/src/main/java/org/apache/skywalking/apm/plugin/pulsar/PulsarConsumerListenerInterceptor.java
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.pulsar;
+
+import org.apache.pulsar.client.api.Message;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.lang.reflect.Method;
+
+/**
+ * Interceptor for pulsar consumer message listener enhanced instance
+ * <p>
+ * Here is the intercept process steps:
+ *
+ * <pre>
+ *  1. Get @{@link ContextCarrier} from message
+ *  2. Create a local span when call <code>received</code> method
+ *  3. Extract trace information from context carrier
+ *  4. Stop the local span when <code>received</code> method finished.
+ * </pre>
+ */
+public class PulsarConsumerListenerInterceptor implements 
InstanceMethodsAroundInterceptor {
+
+    public static final String CONSUMER_OPERATE_NAME = 
"Pulsar/Consumer/MessageListener";

Review comment:
       It's not the same concepts here I think, the `Pulsar/Producer` means the 
client sends out the message, the `Pulsar/Producer/Callback` means the broker 
sends out the publish receipt to the client, if not callback from the broker, 
this means the message does not written succeed. 
   
   But for the message listener, it's a way at the client side to get messages, 
both `Pulsar/Consumer/MessageListener` and `Pulsar/Consumer` are indicate the 
messages are arrivals the consumer, and we are not support the 
`Pulsar/Consumer/Acknowledge` for now to indicate the consumer processed the 
message and acked it.
   
   The reason that I think we don't need a new operation here is we might have 
different get message methods in the client side such as batchReceive etc., I 
think the trace is telling users that the message arrives the consumer is 
enough here, If we want to add more details about how the users get the 
messages, I think we can add some labels in the trace context, but not a new 
operation name.
   
   BTW, do we need to add a new span for handling this case? Looks like
   
   ```
   --- Pulsar/Consumer
         --- Pulsar/Consumer/MessageListener
   ```
   If there is a way to set the existing span to the message listener thread, 
seems more reasonable here.




-- 
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:
[email protected]


Reply via email to