use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpRequestExecuteMethodInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
InnerWhiteListCheckUtil.check();
Object target = advice.getTarget();
final HttpRequest request = (HttpRequest) target;
SpanRecord record = new SpanRecord();
record.setService(request.getUrl().getRawPath());
record.setMethod(StringUtils.upperCase(request.getRequestMethod()));
record.setRemoteIp(request.getUrl().getHost());
record.setPort(request.getUrl().getPort());
final HttpHeaders headers = request.getHeaders();
record.setRequest(new Object[] { headers, request.getUrl().build() });
Long contentLength = headers.getContentLength();
contentLength = contentLength == null ? 0 : contentLength;
record.setRequestSize(contentLength);
record.setRemoteIp(request.getUrl().getHost());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ClientCallStartInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object result = advice.getReturnObj();
if (args == null || args.length != 2) {
return null;
}
if (!(args[1] instanceof Metadata)) {
return null;
}
SpanRecord record = new SpanRecord();
record.setResponse(result == null ? 0 : result);
record.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class FeignMockInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Method method = (Method) args[1];
if (method == null) {
logger.info("[debug] thread {} feign method =null , args: [{}]", Thread.currentThread(), JSON.toJSONString(args));
return null;
}
SpanRecord record = new SpanRecord();
record.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
record.setService(method.getDeclaringClass().getName());
record.setMethod(method.getName() + getParameterTypesString(method.getParameterTypes()));
record.setResponse(advice.getReturnObj());
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpEncoderInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
final HttpMessage httpMessage = (HttpMessage) args[1];
final ChannelHandlerContext channelHandlerContext = (ChannelHandlerContext) args[0];
Map<String, String> context = manager.getDynamicField(httpMessage, NettyConstants.DYNAMIC_FIELD_ASYNC_CONTEXT);
if (!Pradar.hasInvokeContext(context)) {
context = Pradar.getInvokeContextMap();
}
/**
* 如果有上下文,则说明是发送请求,作为客户端
* 否则是作为服务端接收请求
*/
SpanRecord spanRecord = new SpanRecord();
spanRecord.setContext(context);
spanRecord.setRemoteIp(getHost(channelHandlerContext));
spanRecord.setPort(getPort(channelHandlerContext));
spanRecord.setService(getUrl(httpMessage));
spanRecord.setMethod(getMethod(httpMessage));
if (!Pradar.hasInvokeContext(context)) {
spanRecord.setClusterTest(isClusterTestRequest(httpMessage));
Map<String, String> ctx = new HashMap<String, String>();
for (String key : Pradar.getInvokeContextTransformKeys()) {
String value = httpMessage.headers().get(key);
if (value != null) {
ctx.put(key, value);
}
}
if (!ctx.isEmpty()) {
spanRecord.setContext(ctx);
}
}
return spanRecord;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class HttpEncoderInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
SpanRecord record = new SpanRecord();
record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
return record;
}
Aggregations