diff --git a/pom.xml b/pom.xml index d6e3c597..eeef3c7e 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ 4.0.0 com.alipay.sofa bolt - 1.6.9 + 1.6.10 jar ${project.groupId}:${project.artifactId} @@ -85,7 +85,7 @@ UTF-8 1.7.21 - 1.0.12 + 1.4.0 2.4.0 diff --git a/src/main/java/com/alipay/remoting/InvokeContext.java b/src/main/java/com/alipay/remoting/InvokeContext.java index 5cfaf402..b74250c8 100644 --- a/src/main/java/com/alipay/remoting/InvokeContext.java +++ b/src/main/java/com/alipay/remoting/InvokeContext.java @@ -16,6 +16,8 @@ */ package com.alipay.remoting; +import com.alipay.sofa.common.insight.RecordContext; + import java.util.concurrent.ConcurrentHashMap; /** @@ -68,6 +70,11 @@ public class InvokeContext { // ~~~ constants public final static int INITIAL_SIZE = 8; + /** + * record context + */ + private RecordContext recordContext; + /** context */ private ConcurrentHashMap context; @@ -75,6 +82,7 @@ public class InvokeContext { * default construct */ public InvokeContext() { + this.recordContext = new RecordContext(); this.context = new ConcurrentHashMap(INITIAL_SIZE); } @@ -126,6 +134,16 @@ public T get(String key, T defaultIfNotFound) { * clear all mappings. */ public void clear() { + this.recordContext = new RecordContext(); this.context.clear(); } -} \ No newline at end of file + + /** + * Gets get record context. + * + * @return the get record context + */ + public RecordContext getRecordContext() { + return recordContext; + } +} diff --git a/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java b/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java index ff8cac4f..d886c39f 100644 --- a/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java +++ b/src/main/java/com/alipay/remoting/rpc/protocol/RpcRequestProcessor.java @@ -20,6 +20,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.RejectedExecutionException; +import com.alipay.sofa.common.insight.RecordContext; +import com.alipay.sofa.common.insight.RecordScene; +import com.alipay.sofa.common.insight.RecorderManager; import org.slf4j.Logger; import com.alipay.remoting.AbstractRemotingProcessor; @@ -131,19 +134,27 @@ public void process(RemotingContext ctx, RpcRequestCommand cmd, ExecutorService @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void doProcess(final RemotingContext ctx, RpcRequestCommand cmd) throws Exception { - long currentTimestamp = System.currentTimeMillis(); + try { + long currentTimestamp = System.currentTimeMillis(); - preProcessRemotingContext(ctx, cmd, currentTimestamp); - if (ctx.isTimeoutDiscard() && ctx.isRequestTimeout()) { - timeoutLog(cmd, currentTimestamp, ctx);// do some log - return;// then, discard this request - } - debugLog(ctx, cmd, currentTimestamp); - // decode request all - if (!deserializeRequestCommand(ctx, cmd, RpcDeserializeLevel.DESERIALIZE_ALL)) { - return; + RecorderManager.getRecorder().start(RecordScene.BOLT_REQUEST_HANDLE, + new RecordContext(cmd.getId())); + + preProcessRemotingContext(ctx, cmd, currentTimestamp); + if (ctx.isTimeoutDiscard() && ctx.isRequestTimeout()) { + timeoutLog(cmd, currentTimestamp, ctx);// do some log + return;// then, discard this request + } + debugLog(ctx, cmd, currentTimestamp); + // decode request all + if (!deserializeRequestCommand(ctx, cmd, RpcDeserializeLevel.DESERIALIZE_ALL)) { + return; + } + dispatchToUserProcessor(ctx, cmd); + } finally { + RecorderManager.getRecorder().stop(RecordScene.BOLT_REQUEST_HANDLE, + ctx.getInvokeContext().getRecordContext()); } - dispatchToUserProcessor(ctx, cmd); } /**