Search in sources :

Example 91 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class ConsumerMultiRecordEntryPointInterceptor2 method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof List)) {
        return null;
    }
    List<ConsumerRecord> list = (List<ConsumerRecord>) args[0];
    if (list.isEmpty()) {
        return null;
    }
    ConsumerRecord consumerRecord = list.get(0);
    String group = null;
    String remoteAddress = null;
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setRemoteIp(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 ? "" : group);
    spanRecord.setRemoteIp(remoteAddress);
    spanRecord.setCallbackMsg((System.currentTimeMillis() - consumerRecord.timestamp()) + "");
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) HeaderProcessor(com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor) List(java.util.List) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord)

Example 92 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class ConsumerMultiRecordEntryPointInterceptor2 method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof List)) {
        return null;
    }
    List<ConsumerRecord> list = (List<ConsumerRecord>) args[0];
    if (list.isEmpty()) {
        return null;
    }
    ConsumerRecord consumerRecord = list.get(0);
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setRequest(consumerRecord);
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) List(java.util.List) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord)

Example 93 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class LettuceMethodInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    spanRecord.setMiddlewareName(LettuceConstants.MIDDLEWARE_NAME);
    spanRecord.setCallbackMsg(LettuceConstants.PLUGIN_NAME);
    /**
     * 附加属性
     */
    ext();
    return spanRecord;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 94 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class RedissonTraceMethodInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    String methodName = advice.getBehaviorName();
    Object target = advice.getTarget();
    SpanRecord record = new SpanRecord();
    record.setRemoteIp(getHost(target, methodName, args));
    record.setPort(getPort(target, methodName, args));
    record.setMiddlewareName(RedissonConstants.MIDDLEWARE_NAME);
    record.setService(String.valueOf(getDatabase(target, methodName, args)));
    record.setMethod(methodName);
    record.setRequest(toArgs(args));
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 95 with SpanRecord

use of com.pamirs.pradar.interceptor.SpanRecord in project LinkAgent by shulieTech.

the class RedissonTraceMethodInterceptor method afterTrace.

@Override
public SpanRecord afterTrace(Advice advice) {
    Object result = advice.getReturnObj();
    SpanRecord record = new SpanRecord();
    record.setMiddlewareName(RedissonConstants.MIDDLEWARE_NAME);
    record.setResponse(result);
    record.setCallbackMsg(getPluginName());
    attachment(advice.getTarget(), advice.getBehaviorName(), advice.getParameterArray());
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

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