Search in sources :

Example 76 with SpanRecord

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

the class MongoCollectionTraceInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object target = advice.getTarget();
    if (executor == null) {
        final Field executor = ReflectionUtils.getDeclaredField(target, "executor");
        executor.setAccessible(true);
        this.executor = executor;
    }
    MongoCollection mongoCollection = (MongoCollection) target;
    SpanRecord record = new SpanRecord();
    record.setRequest(advice.getParameterArray());
    record.setService(mongoCollection.getNamespace().getFullName());
    record.setMethod(advice.getBehaviorName());
    try {
        Object mongo = executor.get(target);
        if (getAllAddressMethod == null) {
            getAllAddressMethod = ReflectionUtils.getDeclaredMethod(mongo, "getAllAddress", null);
        }
        if (getAllAddressMethod == null) {
            if (mongo$2 == null) {
                final Field this$0 = mongo.getClass().getDeclaredField("this$0");
                this$0.setAccessible(true);
                mongo$2 = this$0;
            }
            mongo = mongo$2.get(mongo);
            getAllAddressMethod = ReflectionUtils.getDeclaredMethod(mongo, "getAllAddress", null);
        }
        if ("com.mongodb.Mongo$2".equals(mongo.getClass().getName())) {
            mongo = mongo$2.get(mongo);
        }
        try {
            record.setRemoteIp(StringUtils.join((List) getAllAddressMethod.invoke(mongo), ","));
        } catch (Throwable e) {
            LOGGER.error("mongodb trace 获取数据库地址失败", e);
        }
    } catch (Throwable e) {
        LOGGER.error("mongodb trace error", e);
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) Field(java.lang.reflect.Field) MongoCollection(com.mongodb.client.MongoCollection) List(java.util.List)

Example 77 with SpanRecord

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

the class MapperMethodExecuteTraceInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    SpanRecord record = new SpanRecord();
    MapperMethod.SqlCommand command = Reflect.on(advice.getTarget()).get(MybatisConstants.DYNAMIC_FIELD_COMMAND);
    record.setService(command.getName());
    record.setMethod(command.getType().name());
    if (advice.getParameterArray().length > 1) {
        record.setRequest(advice.getParameterArray()[1]);
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) MapperMethod(org.apache.ibatis.binding.MapperMethod)

Example 78 with SpanRecord

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

the class SqlSessionOperationInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    SpanRecord record = new SpanRecord();
    record.setService(advice.getTargetClass().getName());
    record.setMethod(advice.getBehaviorName());
    record.setRequest(advice.getParameterArray());
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 79 with SpanRecord

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

the class MongoCollectionInternalTraceInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    SpanRecord record = new SpanRecord();
    record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    record.setRequest(advice.getParameterArray());
    record.setResponse(advice.getThrowable());
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord)

Example 80 with SpanRecord

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

the class DBCollectionTraceInterceptor method afterTrace.

@Override
public SpanRecord afterTrace(Advice advice) {
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_SUCCESS);
    return spanRecord;
}
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