Search in sources :

Example 31 with SpanRecord

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

the class RealCallEnqueueV2Interceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    InnerWhiteListCheckUtil.check();
    Object target = advice.getTarget();
    Request request = null;
    try {
        request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_REQUEST);
    } catch (ReflectException e) {
        request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_ORIGINAL_REQUEST);
    }
    SpanRecord record = new SpanRecord();
    record.setRemoteIp(request.url().getHost());
    record.setPort(request.url().getPort());
    record.setService(request.url().getPath());
    record.setMethod(StringUtils.upperCase(request.method()));
    record.setRequest(request.url().getQuery());
    String header = request.header("content-length");
    if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
        try {
            record.setRequestSize(Integer.valueOf(header));
        } catch (NumberFormatException e) {
        }
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) Request(com.squareup.okhttp.Request) JSONObject(com.alibaba.fastjson.JSONObject) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Example 32 with SpanRecord

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

the class RealCallExecuteV2Interceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    SpanRecord record = new SpanRecord();
    if (advice.getThrowable() instanceof SocketTimeoutException) {
        record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
    } else {
        record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    }
    record.setResponse(advice.getThrowable());
    record.setResponseSize(0);
    InnerWhiteListCheckUtil.check();
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) SocketTimeoutException(java.net.SocketTimeoutException)

Example 33 with SpanRecord

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

the class RealCallExecuteV2Interceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    InnerWhiteListCheckUtil.check();
    Object target = advice.getTarget();
    Request request = null;
    try {
        request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_REQUEST);
    } catch (ReflectException e) {
        request = Reflect.on(target).get(OKHttpConstants.DYNAMIC_FIELD_ORIGINAL_REQUEST);
    }
    SpanRecord record = new SpanRecord();
    record.setRemoteIp(request.url().getHost());
    record.setService(request.url().getPath());
    record.setMethod(StringUtils.upperCase(request.method()));
    record.setRemoteIp(request.url().getHost());
    record.setPort(request.url().getPort());
    record.setRequest(request.url().getQuery());
    String header = request.header("content-length");
    if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
        try {
            record.setRequestSize(Integer.valueOf(header));
        } catch (NumberFormatException e) {
        }
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) Request(com.squareup.okhttp.Request) JSONObject(com.alibaba.fastjson.JSONObject) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Example 34 with SpanRecord

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

the class RealCallExecuteV3Interceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object target = advice.getTarget();
    Call call = (Call) target;
    SpanRecord record = new SpanRecord();
    HttpUrl url = call.request().url();
    record.setRemoteIp(url.host());
    record.setService(url.encodedPath());
    record.setMethod(StringUtils.upperCase(call.request().method()));
    record.setRemoteIp(url.host());
    record.setPort(url.port());
    record.setRequest(url.encodedQuery());
    String header = call.request().header("content-length");
    if (StringUtils.isNotBlank(header) && NumberUtils.isDigits(header)) {
        try {
            record.setRequestSize(Integer.valueOf(header));
        } catch (NumberFormatException e) {
        }
    }
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) ExecutionForwardCall(com.pamirs.pradar.internal.adapter.ExecutionForwardCall) JSONObject(com.alibaba.fastjson.JSONObject)

Example 35 with SpanRecord

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

the class RealCallExecuteV3Interceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    SpanRecord record = new SpanRecord();
    if (advice.getThrowable() instanceof SocketTimeoutException) {
        record.setResultCode(ResultCode.INVOKE_RESULT_TIMEOUT);
    } else {
        record.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    }
    record.setResponse(advice.getThrowable());
    record.setResponseSize(0);
    InnerWhiteListCheckUtil.check();
    return record;
}
Also used : SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) SocketTimeoutException(java.net.SocketTimeoutException)

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