From 83633deae16f6aeecf6aded8a9169d7c98ea7bd9 Mon Sep 17 00:00:00 2001 From: Heng Du Date: Fri, 29 Nov 2019 12:23:18 +0800 Subject: [PATCH] feat(client) plug-in message tracing feature (#1624) * feat(client) seprated the messaging tracing to ons * fix(trace) fix the rpchook is null exception --- client/pom.xml | 13 +- .../consumer/DefaultMQPushConsumer.java | 106 +++-- .../client/producer/DefaultMQProducer.java | 74 ++-- .../client/trace/AsyncTraceDispatcher.java | 413 ------------------ .../rocketmq/client/trace/TraceBean.java | 144 ------ .../rocketmq/client/trace/TraceConstants.java | 28 -- .../rocketmq/client/trace/TraceContext.java | 136 ------ .../client/trace/TraceDataEncoder.java | 173 -------- .../client/trace/TraceDispatcher.java | 51 --- .../client/trace/TraceDispatcherType.java | 22 - .../client/trace/TraceTransferBean.java | 44 -- .../rocketmq/client/trace/TraceType.java | 23 - .../hook/ConsumeMessageTraceHookImpl.java | 114 ----- .../trace/hook/SendMessageTraceHookImpl.java | 98 ----- .../trace/DefaultMQConsumerWithTraceTest.java | 5 +- .../trace/DefaultMQProducerWithTraceTest.java | 7 +- pom.xml | 7 +- 17 files changed, 130 insertions(+), 1328 deletions(-) delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/AsyncTraceDispatcher.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceBean.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceConstants.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceContext.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceDataEncoder.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceDispatcher.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceDispatcherType.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceTransferBean.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/TraceType.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/hook/ConsumeMessageTraceHookImpl.java delete mode 100644 client/src/main/java/org/apache/rocketmq/client/trace/hook/SendMessageTraceHookImpl.java diff --git a/client/pom.xml b/client/pom.xml index 1cf292be..f1b61d3a 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -15,7 +15,8 @@ limitations under the License. --> - + org.apache.rocketmq rocketmq-all @@ -62,5 +63,15 @@ log4j-slf4j-impl test + + org.apache.rocketmq + ons-trace-core + + + org.apache.rocketmq + rocketmq-client + + + diff --git a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java index 339f799f..07239f89 100644 --- a/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java +++ b/client/src/main/java/org/apache/rocketmq/client/consumer/DefaultMQPushConsumer.java @@ -18,7 +18,9 @@ package org.apache.rocketmq.client.consumer; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import java.util.Set; +import org.apache.rocketmq.client.AccessChannel; import org.apache.rocketmq.client.ClientConfig; import org.apache.rocketmq.client.QueryResult; import org.apache.rocketmq.client.consumer.listener.MessageListener; @@ -30,9 +32,6 @@ import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; import org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl; import org.apache.rocketmq.client.log.ClientLogger; -import org.apache.rocketmq.client.trace.AsyncTraceDispatcher; -import org.apache.rocketmq.client.trace.TraceDispatcher; -import org.apache.rocketmq.client.trace.hook.ConsumeMessageTraceHookImpl; import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.common.consumer.ConsumeFromWhere; @@ -42,6 +41,11 @@ import org.apache.rocketmq.common.message.MessageQueue; import org.apache.rocketmq.common.protocol.NamespaceUtil; import org.apache.rocketmq.common.protocol.heartbeat.MessageModel; import org.apache.rocketmq.logging.InternalLogger; +import org.apache.rocketmq.ons.open.trace.core.common.OnsTraceConstants; +import org.apache.rocketmq.ons.open.trace.core.common.OnsTraceDispatcherType; +import org.apache.rocketmq.ons.open.trace.core.dispatch.AsyncDispatcher; +import org.apache.rocketmq.ons.open.trace.core.dispatch.impl.AsyncArrayDispatcher; +import org.apache.rocketmq.ons.open.trace.core.hook.OnsConsumeMessageHookImpl; import org.apache.rocketmq.remoting.RPCHook; import org.apache.rocketmq.remoting.exception.RemotingException; @@ -100,17 +104,15 @@ public class DefaultMQPushConsumer extends ClientConfig implements MQPushConsume *