Search in sources :

Example 81 with SpanRecord

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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 82 with 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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ServerWebExchange(org.springframework.web.server.ServerWebExchange) ServerHttpRequest(org.springframework.http.server.reactive.ServerHttpRequest) URI(java.net.URI)

Example 83 with SpanRecord

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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord)

Example 84 with 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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord)

Example 85 with 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;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) HeaderProcessor(com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord)

Aggregations

SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)199 JSONObject (com.alibaba.fastjson.JSONObject)19 SocketTimeoutException (java.net.SocketTimeoutException)15 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)13 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)11 HashMap (java.util.HashMap)10 List (java.util.List)8 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)6 Request (com.weibo.api.motan.rpc.Request)6 HeaderProcessor (com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor)5 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)5 URI (java.net.URI)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Metadata (io.grpc.Metadata)4 ServerAddress (com.mongodb.ServerAddress)3 Channel (com.rabbitmq.client.Channel)3 Connection (com.rabbitmq.client.Connection)3 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 URL (java.net.URL)3