use of com.rabbitmq.client.impl.AMQImpl.Basic.Deliver in project LinkAgent by shulieTech.
the class ChannelNProcessDeliveryInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
if (ConfigCache.isWorkWithSpring()) {
return null;
}
Object[] args = advice.getParameterArray();
Command command = (Command) args[0];
Deliver method = (Deliver) args[1];
SpanRecord record = new SpanRecord();
record.setService(method.getExchange());
record.setMethod(method.getRoutingKey());
BasicProperties contentHeader = (BasicProperties) command.getContentHeader();
Map<String, Object> headers = contentHeader.getHeaders();
if (headers != null) {
Map<String, String> rpcContext = new HashMap<String, String>();
for (String key : Pradar.getInvokeContextTransformKeys()) {
String value = ObjectUtils.toString(headers.get(key));
if (!StringUtil.isEmpty(value)) {
rpcContext.put(key, value);
}
}
record.setContext(rpcContext);
}
byte[] body = command.getContentBody();
record.setRequestSize(body.length);
record.setRequest(body);
Channel channel = (Channel) advice.getTarget();
Connection connection = channel.getConnection();
record.setRemoteIp(connection.getAddress().getHostAddress());
record.setPort(connection.getPort() + "");
return record;
}
Aggregations