重命名tracer,命名为InvokeMonitor。更准确定义执行监控处理。
This commit is contained in:
parent
b69e61a659
commit
195f4b3ec9
|
|
@ -1,4 +1,4 @@
|
|||
package com.ai.cloud.skywalking.tracer;
|
||||
package com.ai.cloud.skywalking.invoke.monitor;
|
||||
|
||||
import com.ai.cloud.skywalking.buffer.ContextBuffer;
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
|
|
@ -14,17 +14,17 @@ import java.util.Set;
|
|||
|
||||
import static com.ai.cloud.skywalking.conf.Config.BuriedPoint.EXCLUSIVE_EXCEPTIONS;
|
||||
|
||||
public abstract class BaseTracer {
|
||||
public abstract class BaseInvokeMonitor {
|
||||
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(BaseTracer.class);
|
||||
.getLogger(BaseInvokeMonitor.class);
|
||||
|
||||
private static String EXCEPTION_SPLIT = ",";
|
||||
|
||||
private static Set<String> exclusiveExceptionSet = null;
|
||||
|
||||
|
||||
protected ContextData traceBeforeInvoke(Span spanData) {
|
||||
protected ContextData beforeInvoke(Span spanData) {
|
||||
if (Config.BuriedPoint.PRINTF) {
|
||||
logger.debug("TraceId:" + spanData.getTraceId()
|
||||
+ "\tviewpointId:" + spanData.getViewPointId()
|
||||
|
|
@ -38,7 +38,7 @@ public abstract class BaseTracer {
|
|||
return new ContextData(spanData);
|
||||
}
|
||||
|
||||
protected void traceAfterInvoke() {
|
||||
protected void afterInvoke() {
|
||||
try {
|
||||
if (!AuthDesc.isAuth())
|
||||
return;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ai.cloud.skywalking.tracer;
|
||||
package com.ai.cloud.skywalking.invoke.monitor;
|
||||
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import com.ai.cloud.skywalking.logging.LogManager;
|
||||
|
|
@ -9,27 +9,27 @@ import com.ai.cloud.skywalking.model.Identification;
|
|||
import com.ai.cloud.skywalking.protocol.Span;
|
||||
import com.ai.cloud.skywalking.util.ContextGenerator;
|
||||
|
||||
public class LocalMethodTracer extends BaseTracer {
|
||||
public class LocalMethodInvokeMonitor extends BaseInvokeMonitor {
|
||||
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(LocalMethodTracer.class);
|
||||
.getLogger(LocalMethodInvokeMonitor.class);
|
||||
|
||||
public ContextData traceBeforeInvoke(Identification id) {
|
||||
public ContextData beforeInvoke(Identification id) {
|
||||
try {
|
||||
if (!AuthDesc.isAuth())
|
||||
return new EmptyContextData();
|
||||
|
||||
Span spanData = ContextGenerator.generateSpanFromThreadLocal(id);
|
||||
|
||||
return super.traceBeforeInvoke(spanData);
|
||||
return super.beforeInvoke(spanData);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
return new EmptyContextData();
|
||||
}
|
||||
}
|
||||
|
||||
public void traceAfterInvoke(){
|
||||
super.traceAfterInvoke();
|
||||
public void afterInvoke(){
|
||||
super.afterInvoke();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ai.cloud.skywalking.tracer;
|
||||
package com.ai.cloud.skywalking.invoke.monitor;
|
||||
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import com.ai.cloud.skywalking.context.CurrentThreadSpanStack;
|
||||
|
|
@ -11,10 +11,10 @@ import com.ai.cloud.skywalking.protocol.Span;
|
|||
import com.ai.cloud.skywalking.protocol.SpanType;
|
||||
import com.ai.cloud.skywalking.util.ContextGenerator;
|
||||
|
||||
public class RPCClientTracer extends BaseTracer{
|
||||
public class RPCClientInvokeMonitor extends BaseInvokeMonitor {
|
||||
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(RPCClientTracer.class);
|
||||
.getLogger(RPCClientInvokeMonitor.class);
|
||||
|
||||
public ContextData traceBeforeInvoke(Identification id) {
|
||||
try {
|
||||
|
|
@ -34,8 +34,8 @@ public class RPCClientTracer extends BaseTracer{
|
|||
}
|
||||
}
|
||||
|
||||
public void traceAfterInvoke(){
|
||||
super.traceAfterInvoke();
|
||||
public void afterInvoke(){
|
||||
super.afterInvoke();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ai.cloud.skywalking.tracer;
|
||||
package com.ai.cloud.skywalking.invoke.monitor;
|
||||
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import com.ai.cloud.skywalking.context.CurrentThreadSpanStack;
|
||||
|
|
@ -10,10 +10,10 @@ import com.ai.cloud.skywalking.protocol.Span;
|
|||
import com.ai.cloud.skywalking.protocol.SpanType;
|
||||
import com.ai.cloud.skywalking.util.ContextGenerator;
|
||||
|
||||
public class RPCServerTracer extends BaseTracer{
|
||||
public class RPCServerInvokeMonitor extends BaseInvokeMonitor {
|
||||
|
||||
private static Logger logger = LogManager
|
||||
.getLogger(RPCServerTracer.class);
|
||||
.getLogger(RPCServerInvokeMonitor.class);
|
||||
|
||||
public void traceBeforeInvoke(ContextData context, Identification id) {
|
||||
try {
|
||||
|
|
@ -27,14 +27,14 @@ public class RPCServerTracer extends BaseTracer{
|
|||
|
||||
invalidateAllSpanIfIsNotFirstSpan(spanData);
|
||||
|
||||
super.traceBeforeInvoke(spanData);
|
||||
super.beforeInvoke(spanData);
|
||||
} catch (Throwable t) {
|
||||
logger.error(t.getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
||||
public void traceAfterInvoke(){
|
||||
super.traceAfterInvoke();
|
||||
public void afterInvoke(){
|
||||
super.afterInvoke();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2,21 +2,21 @@ package test.ai.cloud.api;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
import com.ai.cloud.skywalking.model.Identification.IdentificationBuilder;
|
||||
|
||||
public class TimeTest {
|
||||
@Test
|
||||
public void test(){
|
||||
RPCClientTracer sender = new RPCClientTracer();
|
||||
RPCClientInvokeMonitor sender = new RPCClientInvokeMonitor();
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
IdentificationBuilder builder = Identification
|
||||
.newBuilder()
|
||||
.viewPoint("1111");
|
||||
sender.traceBeforeInvoke(builder.build());
|
||||
sender.traceAfterInvoke();
|
||||
sender.afterInvoke();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println(end - start + "ms");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.ai.cloud.skywalking.plugin.dubbo;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCServerTracer;
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCServerInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import com.ai.cloud.skywalking.model.ContextData;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
|
@ -22,9 +22,9 @@ public class SWDubboEnhanceFilter implements Filter {
|
|||
boolean isConsumer = context.isConsumerSide();
|
||||
Result result = null;
|
||||
if (isConsumer) {
|
||||
RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
ContextData contextData = clientTracer.traceBeforeInvoke(createIdentification(invoker, invocation));
|
||||
ContextData contextData = rpcClientInvokeMonitor.traceBeforeInvoke(createIdentification(invoker, invocation));
|
||||
String contextDataStr = contextData.toString();
|
||||
|
||||
//追加参数
|
||||
|
|
@ -53,18 +53,18 @@ public class SWDubboEnhanceFilter implements Filter {
|
|||
result = invoker.invoke(invocation);
|
||||
//结果是否包含异常
|
||||
if (result.getException() != null) {
|
||||
clientTracer.occurException(result.getException());
|
||||
rpcClientInvokeMonitor.occurException(result.getException());
|
||||
}
|
||||
} catch (RpcException e) {
|
||||
// 自身异常
|
||||
clientTracer.occurException(e);
|
||||
rpcClientInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
} else {
|
||||
// 读取参数
|
||||
RPCServerTracer serverTracer = new RPCServerTracer();
|
||||
RPCServerInvokeMonitor rpcServerInvokeMonitor = new RPCServerInvokeMonitor();
|
||||
String contextDataStr;
|
||||
|
||||
if (!BugFixAcitve.isActive) {
|
||||
|
|
@ -78,21 +78,21 @@ public class SWDubboEnhanceFilter implements Filter {
|
|||
contextData = new ContextData(contextDataStr);
|
||||
}
|
||||
|
||||
serverTracer.traceBeforeInvoke(contextData, createIdentification(invoker, invocation));
|
||||
rpcServerInvokeMonitor.traceBeforeInvoke(contextData, createIdentification(invoker, invocation));
|
||||
|
||||
try {
|
||||
//执行结果
|
||||
result = invoker.invoke(invocation);
|
||||
//结果是否包含异常
|
||||
if (result.getException() != null) {
|
||||
serverTracer.occurException(result.getException());
|
||||
rpcServerInvokeMonitor.occurException(result.getException());
|
||||
}
|
||||
} catch (RpcException e) {
|
||||
// 自身异常
|
||||
serverTracer.occurException(e);
|
||||
rpcServerInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
serverTracer.traceAfterInvoke();
|
||||
rpcServerInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.skywalking.httpClient.v4.plugin;
|
|||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.HttpRequest;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.enhance.ConstructorInvokeContext;
|
||||
|
|
@ -17,7 +17,7 @@ public class HttpClientExecuteInterceptor implements IntanceMethodsAroundInterce
|
|||
*/
|
||||
public static String TRACE_HEAD_NAME = "SkyWalking-TRACING-NAME";
|
||||
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedClassInstanceContext context,
|
||||
|
|
@ -38,7 +38,7 @@ public class HttpClientExecuteInterceptor implements IntanceMethodsAroundInterce
|
|||
.setHeader(
|
||||
TRACE_HEAD_NAME,
|
||||
"ContextData="
|
||||
+ clientTracer.traceBeforeInvoke(
|
||||
+ rpcClientInvokeMonitor.traceBeforeInvoke(
|
||||
Identification
|
||||
.newBuilder()
|
||||
.viewPoint(
|
||||
|
|
@ -58,7 +58,7 @@ public class HttpClientExecuteInterceptor implements IntanceMethodsAroundInterce
|
|||
// illegal args, can't trace. ignore.
|
||||
return ret;
|
||||
}
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public class HttpClientExecuteInterceptor implements IntanceMethodsAroundInterce
|
|||
// illegal args, can't trace. ignore.
|
||||
return;
|
||||
}
|
||||
clientTracer.occurException(t);
|
||||
rpcClientInvokeMonitor.occurException(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.plugin.jdbc;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -11,13 +11,13 @@ import java.sql.SQLException;
|
|||
* @author wusheng
|
||||
*/
|
||||
public class CallableStatementTracing {
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
public static <R> R execute(java.sql.CallableStatement realStatement,
|
||||
String connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
clientTracer.traceBeforeInvoke(Identification
|
||||
rpcClientInvokeMonitor.traceBeforeInvoke(Identification
|
||||
.newBuilder()
|
||||
.viewPoint(connectInfo)
|
||||
.businessKey(
|
||||
|
|
@ -27,10 +27,10 @@ public class CallableStatementTracing {
|
|||
: ":" + sql)).spanType(JDBCBuriedPointType.instance()).build());
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
clientTracer.occurException(e);
|
||||
rpcClientInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.plugin.jdbc;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -11,13 +11,13 @@ import java.sql.SQLException;
|
|||
* @author wusheng
|
||||
*/
|
||||
public class ConnectionTracing {
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
public static <R> R execute(java.sql.Connection realConnection,
|
||||
String connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
clientTracer.traceBeforeInvoke(Identification
|
||||
rpcClientInvokeMonitor.traceBeforeInvoke(Identification
|
||||
.newBuilder()
|
||||
.viewPoint(connectInfo)
|
||||
.businessKey(
|
||||
|
|
@ -27,10 +27,10 @@ public class ConnectionTracing {
|
|||
: ":" + sql)).spanType(JDBCBuriedPointType.instance()).build());
|
||||
return exec.exe(realConnection, sql);
|
||||
} catch (SQLException e) {
|
||||
clientTracer.occurException(e);
|
||||
rpcClientInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.plugin.jdbc;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -12,13 +12,13 @@ import java.sql.SQLException;
|
|||
*
|
||||
*/
|
||||
public class PreparedStatementTracing {
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
public static <R> R execute(java.sql.PreparedStatement realStatement,
|
||||
String connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
clientTracer.traceBeforeInvoke(Identification
|
||||
rpcClientInvokeMonitor.traceBeforeInvoke(Identification
|
||||
.newBuilder()
|
||||
.viewPoint(connectInfo)
|
||||
.businessKey(
|
||||
|
|
@ -28,10 +28,10 @@ public class PreparedStatementTracing {
|
|||
: ":" + sql)).spanType(JDBCBuriedPointType.instance()).build());
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
clientTracer.occurException(e);
|
||||
rpcClientInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.plugin.jdbc;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
|
@ -11,13 +11,13 @@ import java.sql.SQLException;
|
|||
* @author wusheng
|
||||
*/
|
||||
public class StatementTracing {
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
public static <R> R execute(java.sql.Statement realStatement,
|
||||
String connectInfo, String method, String sql, Executable<R> exec)
|
||||
throws SQLException {
|
||||
try {
|
||||
clientTracer.traceBeforeInvoke(Identification
|
||||
rpcClientInvokeMonitor.traceBeforeInvoke(Identification
|
||||
.newBuilder()
|
||||
.viewPoint(connectInfo)
|
||||
.businessKey(
|
||||
|
|
@ -27,10 +27,10 @@ public class StatementTracing {
|
|||
: ":" + sql)).spanType(JDBCBuriedPointType.instance()).build());
|
||||
return exec.exe(realStatement, sql);
|
||||
} catch (SQLException e) {
|
||||
clientTracer.occurException(e);
|
||||
rpcClientInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ai.cloud.skywalking.jedis.v2.plugin;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.RPCClientTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCClientInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.EnhancedClassInstanceContext;
|
||||
import com.ai.cloud.skywalking.plugin.interceptor.assist.SimpleObjectFirstInvokeInterceptor;
|
||||
|
|
@ -10,7 +10,7 @@ import com.ai.cloud.skywalking.plugin.interceptor.enhance.MethodInterceptResult;
|
|||
public abstract class JedisBaseInterceptor extends SimpleObjectFirstInvokeInterceptor {
|
||||
protected static final String REDIS_CONN_INFO_KEY = "redisClusterConnInfo";
|
||||
|
||||
private static RPCClientTracer clientTracer = new RPCClientTracer();
|
||||
private static RPCClientInvokeMonitor rpcClientInvokeMonitor = new RPCClientInvokeMonitor();
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, MethodInterceptResult result) {
|
||||
|
|
@ -30,20 +30,20 @@ public abstract class JedisBaseInterceptor extends SimpleObjectFirstInvokeInterc
|
|||
builder.businessKey("key="
|
||||
+ interceptorContext.allArguments()[0]);
|
||||
}
|
||||
clientTracer.traceBeforeInvoke(builder.build());
|
||||
rpcClientInvokeMonitor.traceBeforeInvoke(builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
if (this.isLastAfterMethod(context)) {
|
||||
clientTracer.traceAfterInvoke();
|
||||
rpcClientInvokeMonitor.afterInvoke();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(Throwable t, EnhancedClassInstanceContext context, InstanceMethodInvokeContext interceptorContext, Object ret) {
|
||||
clientTracer.occurException(t);
|
||||
rpcClientInvokeMonitor.occurException(t);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
package com.ai.cloud.skywalking.plugin.spring;
|
||||
|
||||
import com.ai.cloud.skywalking.tracer.LocalMethodTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.LocalMethodInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
||||
public class TracingAspect {
|
||||
|
||||
public Object doTracing(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
|
||||
LocalMethodTracer localMethodTracer = new LocalMethodTracer();
|
||||
LocalMethodInvokeMonitor localMethodInvokeMonitor = new LocalMethodInvokeMonitor();
|
||||
try {
|
||||
localMethodTracer.traceBeforeInvoke(Identification.newBuilder().viewPoint(proceedingJoinPoint.getSignature().toString()).spanType(SpringBuriedPointType.instance()).build());
|
||||
localMethodInvokeMonitor.beforeInvoke(Identification.newBuilder().viewPoint(proceedingJoinPoint.getSignature().toString()).spanType(SpringBuriedPointType.instance()).build());
|
||||
return proceedingJoinPoint.proceed();
|
||||
} catch (Throwable e) {
|
||||
localMethodTracer.occurException(e);
|
||||
localMethodInvokeMonitor.occurException(e);
|
||||
throw e;
|
||||
} finally {
|
||||
localMethodTracer.traceAfterInvoke();
|
||||
localMethodInvokeMonitor.afterInvoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ai.cloud.skywalking.plugin.web;
|
|||
|
||||
|
||||
import com.ai.cloud.skywalking.api.Tracing;
|
||||
import com.ai.cloud.skywalking.tracer.RPCServerTracer;
|
||||
import com.ai.cloud.skywalking.invoke.monitor.RPCServerInvokeMonitor;
|
||||
import com.ai.cloud.skywalking.conf.AuthDesc;
|
||||
import com.ai.cloud.skywalking.model.ContextData;
|
||||
import com.ai.cloud.skywalking.model.Identification;
|
||||
|
|
@ -32,7 +32,7 @@ public class SkyWalkingFilter implements Filter {
|
|||
return;
|
||||
}
|
||||
|
||||
RPCServerTracer tracer = null;
|
||||
RPCServerInvokeMonitor rpcServerInvokeMonitor = null;
|
||||
try {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
String tracingHeaderValue = request.getHeader(tracingName);
|
||||
|
|
@ -51,17 +51,17 @@ public class SkyWalkingFilter implements Filter {
|
|||
contextData = new ContextData(contextDataStr);
|
||||
}
|
||||
}
|
||||
tracer = new RPCServerTracer();
|
||||
tracer.traceBeforeInvoke(contextData, generateIdentification(request));
|
||||
rpcServerInvokeMonitor = new RPCServerInvokeMonitor();
|
||||
rpcServerInvokeMonitor.traceBeforeInvoke(contextData, generateIdentification(request));
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
|
||||
httpServletResponse.addHeader(TRACE_ID_HEADER_NAME, Tracing.getTraceId());
|
||||
} catch (Throwable e) {
|
||||
tracer.occurException(e);
|
||||
rpcServerInvokeMonitor.occurException(e);
|
||||
throw new ServletException(e);
|
||||
} finally {
|
||||
tracer.traceAfterInvoke();
|
||||
rpcServerInvokeMonitor.afterInvoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue