Search in sources :

Example 1 with HttpClient3CallContext

use of com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext in project pinpoint by naver.

the class HttpMethodBaseRequestAndResponseMethodInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, methodDescriptor.getClassName(), methodDescriptor.getMethodName(), "", args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
    if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof HttpClient3CallContext) {
        HttpClient3CallContext callContext = (HttpClient3CallContext) invocation.getAttachment();
        if (methodDescriptor.getMethodName().equals("writeRequest")) {
            callContext.setWriteBeginTime(System.currentTimeMillis());
        } else {
            callContext.setReadBeginTime(System.currentTimeMillis());
        }
        logger.debug("Set call context {}", callContext);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) HttpClient3CallContext(com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext)

Example 2 with HttpClient3CallContext

use of com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext in project pinpoint by naver.

the class HttpMethodBaseExecuteMethodInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (target instanceof HttpMethod) {
            HttpMethod httpMethod = (HttpMethod) target;
            recordDestination(trace, httpMethod, args);
            recordRequest(trace, httpMethod, throwable);
        }
        if (result != null) {
            recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, result);
        }
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
        final HttpClient3CallContext callContext = getAndCleanAttachment();
        if (callContext != null) {
            recordIo(recorder, callContext);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) HttpClient3CallContext(com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 3 with HttpClient3CallContext

use of com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext in project pinpoint by naver.

the class HttpMethodBaseRequestAndResponseMethodInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, methodDescriptor.getClassName(), methodDescriptor.getMethodName(), "", args, result, throwable);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
    if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof HttpClient3CallContext) {
        HttpClient3CallContext callContext = (HttpClient3CallContext) invocation.getAttachment();
        if (methodDescriptor.getMethodName().equals("writeRequest")) {
            callContext.setWriteEndTime(System.currentTimeMillis());
            callContext.setWriteFail(throwable != null);
        } else {
            callContext.setReadEndTime(System.currentTimeMillis());
            callContext.setReadFail(throwable != null);
        }
        logger.debug("Set call context {}", callContext);
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) HttpClient3CallContext(com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext)

Aggregations

Trace (com.navercorp.pinpoint.bootstrap.context.Trace)3 HttpClient3CallContext (com.navercorp.pinpoint.plugin.httpclient3.HttpClient3CallContext)3 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 HttpMethod (org.apache.commons.httpclient.HttpMethod)1