Search in sources :

Example 1 with UserRequestGetter

use of com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter in project pinpoint by naver.

the class HttpEngineSendRequestMethodInterceptor 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;
    }
    if (!validate(target)) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordException(throwable);
        // clear attachment.
        final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
        final Object attachment = getAttachment(invocation);
        if (attachment != null) {
            invocation.removeAttachment();
        }
        // typeCheck validate();
        final Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest();
        if (request != null) {
            this.clientRequestRecorder.record(recorder, request, throwable);
            this.cookieRecorder.record(recorder, request, throwable);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) UserRequestGetter(com.navercorp.pinpoint.plugin.okhttp.v3.UserRequestGetter) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) Request(okhttp3.Request)

Example 2 with UserRequestGetter

use of com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter in project pinpoint by naver.

the class HttpEngineSendRequestMethodInterceptor 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;
    }
    if (!validate(target)) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        recorder.recordApi(methodDescriptor);
        recorder.recordException(throwable);
        // clear attachment.
        final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
        final Object attachment = getAttachment(invocation);
        if (attachment != null) {
            invocation.removeAttachment();
        }
        // typeCheck validate();
        final Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest();
        if (request != null) {
            this.clientRequestRecorder.record(recorder, request, throwable);
            this.cookieRecorder.record(recorder, request, throwable);
        }
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) InterceptorScopeInvocation(com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation) UserRequestGetter(com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) Request(com.squareup.okhttp.Request)

Example 3 with UserRequestGetter

use of com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter in project pinpoint by naver.

the class HttpEngineConnectMethodInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
    recorder.recordException(throwable);
    if (target instanceof UserRequestGetter) {
        final Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest();
        if (request != null && request.url() != null) {
            final HttpUrl httpUrl = request.url();
            final String hostAndPort = HostAndPort.toHostAndPortString(httpUrl.host(), httpUrl.port());
            recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
        }
    }
}
Also used : UserRequestGetter(com.navercorp.pinpoint.plugin.okhttp.v3.UserRequestGetter) Request(okhttp3.Request) HttpUrl(okhttp3.HttpUrl)

Example 4 with UserRequestGetter

use of com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter in project pinpoint by naver.

the class HttpEngineConnectMethodFromUserRequestInterceptor method doInAfterTrace.

@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
    recorder.recordApi(methodDescriptor);
    recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
    recorder.recordException(throwable);
    if (target instanceof UserRequestGetter) {
        final Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest();
        if (request != null && request.httpUrl() != null) {
            final HttpUrl httpUrl = request.httpUrl();
            final String hostAndPort = HostAndPort.toHostAndPortString(httpUrl.host(), httpUrl.port());
            recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
        }
    }
}
Also used : UserRequestGetter(com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter) Request(com.squareup.okhttp.Request) HttpUrl(com.squareup.okhttp.HttpUrl)

Aggregations

SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 InterceptorScopeInvocation (com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation)2 UserRequestGetter (com.navercorp.pinpoint.plugin.okhttp.v2.UserRequestGetter)2 UserRequestGetter (com.navercorp.pinpoint.plugin.okhttp.v3.UserRequestGetter)2 Request (com.squareup.okhttp.Request)2 Request (okhttp3.Request)2 HttpUrl (com.squareup.okhttp.HttpUrl)1 HttpUrl (okhttp3.HttpUrl)1