use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ChannelNBasicPublishInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args.length == 0) {
return null;
}
String exchange = (String) args[0];
String routingKey = (String) args[1];
byte[] body = (byte[]) args[5];
SpanRecord record = new SpanRecord();
Channel channel = (Channel) advice.getTarget();
Connection connection = channel.getConnection();
record.setRemoteIp(connection.getAddress().getHostAddress());
record.setPort(connection.getPort() + "");
record.setService(exchange);
record.setMethod(routingKey);
record.setRequestSize(body.length);
record.setRequest(body);
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class QueueingConsumerHandleInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args.length == 0 || args[0] == null) {
return null;
}
Object target = advice.getTarget();
Class<?>[] classes = target.getClass().getClasses();
if (classes.length != 1) {
return null;
}
Object deliveryObj = args[0];
if (deliveryObj == null) {
return null;
}
SpanRecord record = new SpanRecord();
try {
Envelope envelope = Reflect.on(deliveryObj).get(RabbitmqConstants.DYNAMIC_FIELD_ENVELOPE);
if (envelope == null) {
// 说明是毒药,已经报错了
return null;
}
record.setService(envelope.getExchange());
record.setMethod(envelope.getRoutingKey());
} catch (ReflectException e) {
}
try {
AMQP.BasicProperties properties = Reflect.on(deliveryObj).get(RabbitmqConstants.DYNAMIC_FIELD_PROPERTIES);
Map<String, Object> headers = properties.getHeaders();
if (headers != null) {
Map<String, String> rpcContext = new HashMap<String, String>();
for (String key : Pradar.getInvokeContextTransformKeys()) {
Object tmp = headers.get(key);
if (tmp != null) {
String value = tmp.toString();
if (!StringUtil.isEmpty(value)) {
rpcContext.put(key, value);
}
}
}
record.setContext(rpcContext);
}
} catch (ReflectException e) {
}
try {
byte[] body = Reflect.on(deliveryObj).get(RabbitmqConstants.DYNAMIC_FIELD_BODY);
record.setRequestSize(body.length);
record.setRequest(body);
} catch (ReflectException e) {
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class QueueingConsumerHandleInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args.length == 0 || args[0] == null) {
return null;
}
Object target = advice.getTarget();
Class<?>[] classes = target.getClass().getClasses();
if (classes.length != 1) {
return null;
}
Object deliveryObj = args[0];
if (deliveryObj == null) {
return null;
}
SpanRecord record = new SpanRecord();
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
record.setResponse(advice.getThrowable());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class SpringBlockingQueueConsumerDeliveryInterceptorV2 method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args[0] == null) {
return null;
}
SpanRecord record = new SpanRecord();
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
record.setResponse(advice.getThrowable());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class SpringBlockingQueueConsumerDeliveryInterceptorV2 method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args[0] == null) {
return null;
}
SpanRecord record = new SpanRecord();
return record;
}
Aggregations