Commit 83d052ae by QIANGLU

添加防灾冗余

parent 987c8adf
......@@ -21,6 +21,10 @@
<artifactId>apollo-client</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>monitor-starter</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -21,43 +21,32 @@ public class LoggerFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
long startTime = System.currentTimeMillis();
RpcContext rpcContext = RpcContext.getContext();
URL url = rpcContext.getUrl();
String who = url.getParameter("side");
String serviceName = url.getParameter("application");
//CONSUMER 从MDC中获取RPCID并增加其序列,传递最新序列唯一ID到下一层
try {
String who = url.getParameter("side");
//CONSUMER 从MDC中获取RPCID并增加其序列,传递最新序列唯一ID到下一层
if (MonitorConstant.CONSUMER.equals(who)) {
if (MonitorConstant.CONSUMER.equals(who)) {
String traceId = TraceIDUtils.continueTraceID();
rpcContext.setAttachment(MonitorConstant.TRACE_ID, traceId);
String traceId = TraceIDUtils.continueTraceID();
rpcContext.setAttachment(MonitorConstant.TRACE_ID, traceId);
LOG.info("consumer: source[{}, {}], target[{}],arguments[{}]",
rpcContext.getLocalAddressString(), serviceName,
rpcContext.getRemoteAddressString(), rpcContext.getArguments());
} else if (MonitorConstant.PROVIDER.equals(who)) {
MDC.remove(MonitorConstant.TRACE_ID);
MDC.remove("rpcId");
String traceId = rpcContext.getAttachment(MonitorConstant.TRACE_ID);
TraceIDUtils.childTraceID(traceId);
}
} else if (MonitorConstant.PROVIDER.equals(who)) {
MDC.remove(MonitorConstant.TRACE_ID);
MDC.remove("rpcId");
String traceId = rpcContext.getAttachment(MonitorConstant.TRACE_ID);
TraceIDUtils.childTraceID(traceId);
} catch (Exception e) {
LOG.info("provider: source[{}], target[{}, {}],arguments[{}]",
rpcContext.getRemoteAddressString(), rpcContext.getLocalAddressString(),
serviceName, rpcContext.getArguments());
}
Result result = invoker.invoke(invocation);
long stopTime = System.currentTimeMillis();
LOG.info("service[{}] is finished, waste time [{}ms] ", serviceName, stopTime - startTime);
return result;
return invoker.invoke(invocation);
}
}
......@@ -97,6 +97,11 @@
<dependencies>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>monitor-starter</artifactId>
<version>1.0.3-DEV-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>common-core</artifactId>
<version>1.0.3-DEV-SNAPSHOT</version>
</dependency>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment