use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class DBCollectionTraceInterceptor method exceptionTrace.
@Override
public SpanRecord exceptionTrace(Advice advice) {
SpanRecord spanRecord = new SpanRecord();
spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
return spanRecord;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class GatewayFilterChainFilterInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(final Advice advice) {
final Object[] parameterArray = advice.getParameterArray();
ServerWebExchange exchange = (ServerWebExchange) parameterArray[0];
ServerHttpRequest request = exchange.getRequest();
URI requestUrl = exchange.getRequiredAttribute(GATEWAY_REQUEST_URL_ATTR);
// 添加压测数据到header
SpanRecord record = new SpanRecord();
record.setRemoteIp(requestUrl.getHost());
record.setService(request.getPath().toString());
record.setMethod(StringUtils.upperCase(request.getMethodValue()));
record.setPort(requestUrl.getPort());
final Map<String, String> stringStringMap = request.getQueryParams().toSingleValueMap();
if (!stringStringMap.isEmpty()) {
StringBuilder params = new StringBuilder();
for (Entry<String, String> entry : stringStringMap.entrySet()) {
params.append(entry.getKey()).append("=").append(entry.getValue()).append(",");
}
record.setRequest(params.toString());
record.setRequestSize(params.length());
} else {
record.setRequestSize(0);
}
return record;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ConsumerRecordEntryPointInterceptor method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object result = advice.getReturnObj();
ConsumerRecord consumerRecord = (ConsumerRecord) args[0];
SpanRecord spanRecord = new SpanRecord();
spanRecord.setRequest(consumerRecord);
spanRecord.setResponse(result);
spanRecord.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return spanRecord;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ConsumerRecordEntryPointInterceptor2 method afterTrace.
@Override
public SpanRecord afterTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object result = advice.getReturnObj();
ConsumerRecord consumerRecord = (ConsumerRecord) args[0];
SpanRecord spanRecord = new SpanRecord();
spanRecord.setRequest(consumerRecord);
spanRecord.setResponse(result);
spanRecord.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
return spanRecord;
}
use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.
the class ConsumerRecordEntryPointInterceptor2 method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
ConsumerRecord consumerRecord = (ConsumerRecord) args[0];
String group = null;
long consumerCell = System.currentTimeMillis() - consumerRecord.timestamp();
String remoteAddress = null;
if (args.length >= 3) {
remoteAddress = KafkaUtils.getRemoteAddress(args[2], manager);
}
SpanRecord spanRecord = new SpanRecord();
spanRecord.setRemoteIp(remoteAddress == null ? "127.0.0.1:9092" : remoteAddress);
if (PradarSwitcher.isKafkaMessageHeadersEnabled()) {
HeaderProcessor headerProcessor = HeaderProvider.getHeaderProcessor(consumerRecord);
Map<String, String> ctx = headerProcessor.getHeaders(consumerRecord);
spanRecord.setContext(ctx);
}
spanRecord.setRequest(consumerRecord);
spanRecord.setService(consumerRecord.topic());
spanRecord.setMethod(group == null ? groupGlobal : group);
spanRecord.setCallbackMsg(consumerCell + "");
return spanRecord;
}
Aggregations