Search in sources :

Example 11 with Request

use of com.ning.http.client.Request in project pinpoint by naver.

the class ExecuteRequestInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    final Trace trace = traceContext.currentRawTraceObject();
    if (trace == null) {
        return;
    }
    Request httpRequest = getHttpReqeust(args);
    if (httpRequest == null) {
        return;
    }
    final boolean sampling = trace.canSampled();
    if (!sampling) {
        this.requestTraceWriter.write(httpRequest);
        return;
    }
    trace.traceBlockBegin();
    final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
    final TraceId nextId = trace.getTraceId().getNextTraceId();
    recorder.recordNextSpanId(nextId.getSpanId());
    recorder.recordServiceType(NingAsyncHttpClientConstants.ASYNC_HTTP_CLIENT);
    String host = getHost(httpRequest);
    requestTraceWriter.write(httpRequest, nextId, host);
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) Request(com.ning.http.client.Request) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId)

Example 12 with Request

use of com.ning.http.client.Request in project pinpoint by naver.

the class ExecuteRequestInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        // Do not log result
        logger.afterInterceptor(target, args);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    Request httpReqeust = getHttpReqeust(args);
    if (httpReqeust == null) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        final Request httpRequest = (Request) args[0];
        // Accessing httpRequest here not BEFORE() because it can cause side effect.
        this.clientRequestRecorder.record(recorder, httpRequest, throwable);
        this.cookieRecorder.record(recorder, httpRequest, throwable);
        this.entityRecorder.record(recorder, httpRequest, throwable);
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) Request(com.ning.http.client.Request)

Aggregations

Request (com.ning.http.client.Request)12 IOException (java.io.IOException)8 RequestBuilder (com.ning.http.client.RequestBuilder)6 Response (com.ning.http.client.Response)5 HttpResponseBodyPart (com.ning.http.client.HttpResponseBodyPart)4 AsyncHttpClient (com.ning.http.client.AsyncHttpClient)3 AsyncHttpClientConfig (com.ning.http.client.AsyncHttpClientConfig)3 NettyAsyncHttpProvider (com.ning.http.client.providers.netty.NettyAsyncHttpProvider)3 HttpRequest (io.netty.handler.codec.http.HttpRequest)3 ExecutionException (java.util.concurrent.ExecutionException)3 Test (org.junit.Test)3 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 HttpResponseHeaders (com.ning.http.client.HttpResponseHeaders)2 HttpResponseStatus (com.ning.http.client.HttpResponseStatus)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2