use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class MongoCollectionTraceInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object target = advice.getTarget();
if (executor == null) {
final Field executor = ReflectionUtils.getDeclaredField(target, "executor");
executor.setAccessible(true);
this.executor = executor;
}
MongoCollection mongoCollection = (MongoCollection) target;
SpanRecord record = new SpanRecord();
record.setRequest(advice.getParameterArray());
record.setService(mongoCollection.getNamespace().getFullName());
record.setMethod(advice.getBehaviorName());
try {
Object mongo = executor.get(target);
if (getAllAddressMethod == null) {
getAllAddressMethod = ReflectionUtils.getDeclaredMethod(mongo, "getAllAddress", null);
}
if (getAllAddressMethod == null) {
if (mongo$2 == null) {
final Field this$0 = mongo.getClass().getDeclaredField("this$0");
this$0.setAccessible(true);
mongo$2 = this$0;
}
mongo = mongo$2.get(mongo);
getAllAddressMethod = ReflectionUtils.getDeclaredMethod(mongo, "getAllAddress", null);
}
if ("com.mongodb.Mongo$2".equals(mongo.getClass().getName())) {
mongo = mongo$2.get(mongo);
}
try {
record.setRemoteIp(StringUtils.join((List) getAllAddressMethod.invoke(mongo), ","));
} catch (Throwable e) {
LOGGER.error("mongodb trace 获取数据库地址失败", e);
}
} catch (Throwable e) {
LOGGER.error("mongodb trace error", e);
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class MapperMethodExecuteTraceInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
SpanRecord record = new SpanRecord();
MapperMethod.SqlCommand command = Reflect.on(advice.getTarget()).get(MybatisConstants.DYNAMIC_FIELD_COMMAND);
record.setService(command.getName());
record.setMethod(command.getType().name());
if (advice.getParameterArray().length > 1) {
record.setRequest(advice.getParameterArray()[1]);
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class SqlSessionOperationInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
SpanRecord record = new SpanRecord();
record.setService(advice.getTargetClass().getName());
record.setMethod(advice.getBehaviorName());
record.setRequest(advice.getParameterArray());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class MongoCollectionInternalTraceInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
SpanRecord record = new SpanRecord();
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
record.setRequest(advice.getParameterArray());
record.setResponse(advice.getThrowable());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class DBCollectionTraceInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
SpanRecord spanRecord = new SpanRecord();
spanRecord.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return spanRecord;
}
Aggregations